Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Extend FormController's API to access list of form fields #14749

@slavafomin

Description

@slavafomin

Hello!

Thank you for your hard work!

I want to propose a feature to list fields of the form.

Right now we can access individual form fields using form[fieldName] expression. However, form controller has a lot of properties and methods, so it's not possible to iterate the list of form fields directly.

I have to use this code to iterate all fields of the form:

var fields = ['firstName', 'lastName', 'email'];
angular.forEach(fields, function (fieldName) {
  var field = form[fieldName];
  // ...
});

However, it's a bad practice to hardcode array of field names this way.

The proposed API will allow us to do something like this:

angular.forEach(form.$fields, function (field) {
  // ...
});

The other workaround is to iterate all properties of the form controller and detect ngModel objects, however it is also somewhat ugly.

I hope it makes sense. Thank you!

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy