I am nesting ng-repeat in my App.
In that I'm trying to refer to the $index of parent loop
.div(ng-repeat= item in items)
p(ng-repeat= detail in item.details)
a(href='#') // $$ index ?
how do i refer to the $index of the parent loop (ie. $index of item) inside a nested ng-repeat?
(the above code is in jade)
Note: The $index variable is used to get the Index of the Row created by ng-repeat directive. Each row of the HTML Table consists of a Button which has been assigned ng-click directive. The $index variable is passed as parameter to the GetRowIndex function.
You can use $last variable within ng-repeat directive. Take a look at doc. Where computeCssClass is function of controller which takes sole argument and returns 'last' or null .
You can nest two ng-repeat together in order to create a more complex table. The first ng-repeat in the tr tag will create the rows and the second one in the td tag will create one column per element in the collection.
Directives that Create Scopes In most cases, directives and scopes interact but do not create new instances of scope. However, some directives, such as ng-controller and ng-repeat, create new child scopes and attach the child scope to the corresponding DOM element.
Use scope' parent' $index
: $parent.$index
. Something like (just guess , i don't know much about Jade):
.div(ng-repeat= item in items)
p(ng-repeat= detail in item.details)
a(ng-href='#/{{$parent.$index}}')
Working example (not Jade): http://jsfiddle.net/Ysxsx/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With