An example of a real project is to traverse the rows and columns of the table, each row needs to display the current first few lines, I immediately thought of using $index, just like chopping melon cut vegetables, everything so flowing, it is too easy, so the following code.
<!--repeat data row-->
<tr ng-repeat= "row in rows track by Row.id" >
<td ng-repeat= "Col in Row.col Umns track by Col.id ">
<span ng-if=" col.id = 0 "ng-bind=" $index "></span>
</td>
< /tr>
But when my program ran, I found that I was getting the $index feel strange, I think it must be the way I open the wrong, I am crazy to press a few F5, but the fact is that my program out of the bug, because it is the index of the column loop. I'm so crazy about this. Are you messing with me?
After thinking, I thought of the nginit, so I have the following code,
What I'm trying to do is assign the $index to the Outerindex and output the Outerindex in the loop body.
<tr ng-repeat= "row in rows track by Row.id" ng-init= "Outerindex = $index" >
<td ng-repeat= "Col in Row.columns Track by Col.id ">
<span ng-if=" col.id = 0 "ng-bind=" outerindex "></span>
</td>
</tr>
At this time the success achieved the desired results. Although this small problem is very simple, but for angular novice is still very egg ache, feel the answer is ready, but also say,
A little record, my road to Angularjs has just begun.
The above is the Angularjs ng-repeat nesting how to obtain the outer $index data collation, follow-up continue to supplement the relevant information, thank you for your support of this site!