Johann
Johann

Reputation: 29867

Setting a custom attribute

In my AngularJS app my controller sets customer info like this:

$scope.customers = [{'name': 'John', 'customerID': '1'}, {'name': 'Mike', 'customerID': '2'}];

How can I store the customer's ID in the custom attribute cid?:

<div ng-repeat="customer in customers" cid=""></div>

Upvotes: 1

Views: 34

Answers (2)

t0mpl
t0mpl

Reputation: 5025

like this

<div ng-repeat="customer in customers" cid="{{customer.customerID}}"></div>

Upvotes: 0

Liad Livnat
Liad Livnat

Reputation: 7475

you need to do something like this:

<div ng-repeat="customer in customers" cid="{{customer.customerID}}"></div>

but the valid html way is to add "data-" before cid:

<div ng-repeat="customer in customers" data-cid="{{customer.customerID}}"></div>

Upvotes: 1

Related Questions