1

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
1
  • 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 ^^ Commented Jul 19, 2014 at 13:29

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

Doesn't work without the handlebars: cid="{{customer.customerID}}"
0

like this

<div ng-repeat="customer in customers" cid="{{customer.customerID}}"></div>
answered Jul 19, 2014 at 12:27

2 Comments

Sorry but you apparently need the handlebars: cid="{{customer.customerID}}"
i usualy use it to concat in special attributes (like ng-src), or to display $scope outside of HTML tag

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.