AngularJS嵌套NG-重复范围 [英] AngularJS nested ng-repeat scope
本文介绍了AngularJS嵌套NG-重复范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<div ng-repeat="store in stores">
.. some html ..
<div ng-repeat="item in store.items | limitTo: 50">
... item html ...
</div>
<div ng-show="store.items.length > 50">
<button ng-click="">Show all</button>
</div>
</div>
当有人点击该按钮,我想告诉所有的项目,而不只是第50我该怎么做呢?如果我在我的控制器有一个 $ scope.itemCount = 50
,那么这将适用于所有商店和所有项目。我想这是只为store.items的范围。
When someone clicks the button, I want to show all of the items, not just the first 50. How do I do this? If I have a $scope.itemCount = 50
in my controller, then that'll apply for ALL stores and all items. I want it to be only for the scope of store.items.
任何帮助吗?
推荐答案
试试这个:
<div ng-repeat="store in stores" ng-init="storeCount = itemCount">
.. some html ..
<div ng-repeat="item in store.items | limitTo: storeCount">
... item html ...
</div>
<div ng-show="store.items.length > storeCount">
<button ng-click="storeCount = store.items.length">Show all</button>
</div>
</div>
这篇关于AngularJS嵌套NG-重复范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文