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>
asked Jul 19, 2014 at 12:26
Johann
30.1k45 gold badges190 silver badges326 bronze badges
-
sorry to bother you but what you are asking for it's no sense imo if you do like data-cid="{{customer.customerID}}" the value change for all the users and you ended up with the value of the last user id ^^Whisher– Whisher2014年07月19日 13:29:25 +00:00Commented Jul 19, 2014 at 13:29
2 Answers 2
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>
answered Jul 19, 2014 at 12:28
Liad Livnat
7,49517 gold badges62 silver badges98 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Johann
Doesn't work without the handlebars: cid="{{customer.customerID}}"
like this
<div ng-repeat="customer in customers" cid="{{customer.customerID}}"></div>
answered Jul 19, 2014 at 12:27
t0mpl
5,0553 gold badges34 silver badges37 bronze badges
default