我如何在嵌套的ng-repeat中引用父循环的$ index?

时间:2021-08-05 20:33:14

I am nesting ng-repeat in my App.

我正在我的应用程序中嵌套ng-repeat。

In that I'm trying to refer to the $index of parent loop

因为我试图引用父循环的$ index

.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?

我如何在嵌套的ng-repeat中引用父循环的$ index(即$ item of item)?

(the above code is in jade)

(上面的代码是玉)

1 个解决方案

#1


11  

Use scope' parent' $index: $parent.$index. Something like (just guess , i don't know much about Jade):

使用范围'parent'$ index:$ parent。$ index。有点像(只是猜测,我不太了解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/

工作示例(不是Jade):http://jsfiddle.net/Ysxsx/

#1


11  

Use scope' parent' $index: $parent.$index. Something like (just guess , i don't know much about Jade):

使用范围'parent'$ index:$ parent。$ index。有点像(只是猜测,我不太了解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/

工作示例(不是Jade):http://jsfiddle.net/Ysxsx/