Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start $index at 1 in Ng Repeat

Is there a way to use 1 instead of 0 for $index in ng-repeat as the initial item? Im not trying to filter out the first item in the array. It is for paypal they want the first to be item_num_1... using 0 doesnt work as in

<div ng-repeat = "item in items">
<input type ="hidden" name ="item_num_{{$index}}" value ="item_num_{{item.id}}">
//the rest like this
</div>
like image 378
user718229 Avatar asked Dec 05 '22 18:12

user718229


2 Answers

Maybe you can try this. I am not sure if it works though. Good luck

<div ng-repeat = "item in items track by $index">
<input type ="hidden" name ="item_num_{{$index + 1}}" value ="item_num_{{item.id}}">
//the rest like this
</div>
like image 190
Dion Haneveld Avatar answered Dec 31 '22 17:12

Dion Haneveld


Why not to do just

{{$index+1}}
like image 20
Stepan Suvorov Avatar answered Dec 31 '22 19:12

Stepan Suvorov