我正在使用一次性绑定和kcd-recompile,但嵌套ng-repeat
存在问题。我们假设代码如下所示:
<div ng-repeat="person in ::people">
<div ng-repeat="friend in ::person.friends" kcd-recompile="person.friends">
{{friend.name}}
</div>
</div>
如果我现在向其中一个人添加一个朋友,我希望重新编译此人div而不重新编译其他人的div。问题是:person.friends
仅在person
更新后才会更新。
如果我将kcd-recompile
添加到第一个ng-repeat
,那么它会起作用,但随后会重新编译每个人的div(我想阻止它)。
是否有可能在不重新编译整个person
的情况下更新ng-repeat
?
答案 0 :(得分:0)
如果有人需要,我自己(下班后)找到解决方案:
使用people[$index].friends
代替person.friends
,它有效!
<div ng-repeat="person in ::people">
<div ng-repeat="friend in people[$index].friends" kcd-recompile="person.friends">
{{friend.name}}
</div>
</div>