使用AngularJS ng-repeat
,我正在過濾一個人員列表。生成的人員列表被傳遞給變量filtered
。我想顯示filtered.length
。當ng-repeat過濾器更新時AngularJS過濾結果不會更新
過濾器正常工作並在調整過濾器時顯示正確的人員,但有多少人(即filtered.length
)有時不會更新。
這似乎很奇怪:
<br><br>
People Selected: {{filtered.length}}<br><br>
Cost: {{filtered.length*0.01 | currency}}
</div>
<div class="span10">
<br><br>
<table class="people">
<tr ng-repeat="person in (filtered = (data.people | filter:okay))">
<td>{{person.age}} - {{person.gender}} - {{person.tags}}</td>
</tr>
</table>
</div>
但似乎如果我展示filtered.length
在頁面的底部,ng-repeat
後,它的工作原理。如果我把它放在最上面,它只能在80%的時間內工作。
嘗試移動所述過濾器到控制器作爲一個功能,並且可以更新與所得陣列的長度的範圍可變 – charlietfl 2013-03-24 16:34:13