gpt4 book ai didi

angularjs - 如何定义具有 2 ng-repeats 的序列号?

转载 作者:太空宇宙 更新时间:2023-11-03 23:30:23 24 4
gpt4 key购买 nike

$index 不起作用,因为当内部 ng-repeat 触发时,它会执行 $index,当它完全执行时,它会将外部 ng-repeat 的 $index 值清空。在这种情况下如何给出序列号。?

最佳答案

当您使用 ng-repeat 时,它会创建一个子作用域。因此,在嵌套 ng-repeats 的情况下,您可以通过 $parent 到达父级。

因此,你可以这样做:

<div ng-repeat="a in serial1">
<div ng-repeat="b in serial2">
a is {{$parent.$index}}, b is {{$index}}
</div>
</div>

关于angularjs - 如何定义具有 2 ng-repeats 的序列号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39003687/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com