Alex
Alex

Reputation: 646

How to access Angular form element's attributes

Let's say we have some form

<form name="myForm" data-ng-controller="Ctrl">
    <input name="input" data-ng-model="userType" data-description="User Type" required>
</form>

In controller, we can access that input element by code

$scope.myForm.userType

But how can we get data-* attributes of this element?

Upvotes: 4

Views: 1807

Answers (1)

Sjoerd222888
Sjoerd222888

Reputation: 3476

You can use:

angular.element(selector).attr("data-description")

to select elements as you would do with jQuery.

Upvotes: 5

Related Questions