3

I'm looking to increment my input ID while using ng-repeat and I tried this but it doesn't work :

<div ng-repeat="d in index">

<input type="checkbox" name="name" value="" id="{{d}}" ng-model="{{d}}"/>

</div>

Do you have any ideas about how to do it?

2 Answers 2

2

you can track by $index your ng-repeat

div ng-repeat="d in index track by $index"
  input type="checkbox" name="name" value="" id="{{$index}}" ng-model="{{d}}"/
/div
Sign up to request clarification or add additional context in comments.

Comments

1

Try This

<div ng-repeat="d in index track by $index">

<input type="checkbox" name="name" value="" id="{{$index}}" ng-model="d"/>

</div>

dynamic id ng-repeat

2 Comments

thanks for your help , but it doesn't work , to explain what I want to do is to make this dynamic to make many input's from a JSON file : <div class="class1"> <input type="checkbox" name="" value="" id="check2" ng-model="check2" ng-change="getChecked2()"> <label for="check2" class="check"></label> <label for="check2">{{VarServices[0].DesignationFR}} {{VarServices[0].Prix}} $ </label> </div>
if you have differnet model for every checkbox so you can get value by different models

Your Answer

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.