Assign dynamic id in Angular JS

Assign dynamic id in Angular JS

One can use ng-attr to assign dynamic id in angular js.

Not only this, if we want to associate a label to form control with dynamic id, then the for attribute of label should also be dynamic.

ng-attr can also be used for dynamic custom attribute.

ng-attr-id="{{ parameters.name }}"   // for dynamic id
ng-attr-for="{{ parameters.name }}"  // for dynamic for
ng-attr-customAttr="{{ parameters.name }}"  // for dynamic customAttr

Leave a comment