Skip to content Skip to sidebar Skip to footer

How To Get An Element's Attribute With Angularjs

I have the following code:

Solution 2:

Angular comes with jqLite built in, which still has the attr() function. But it's not the Angular "way" to be manually fiddling around in the DOM from a controller. Your scope should be the interface between them.

I'm curious as to why you have a value in an attribute in your UI that isn't defined first in your model / scope? How does this value get changed? Is there a reason why you can't set it in the controller:

$scope.start = 2;

and then:

<input data-ng-model="typeId" name="typeId" type="hidden"data-start="{{start}}" />

Can you explain a little about what data-start is meant to do?

Post a Comment for "How To Get An Element's Attribute With Angularjs"