I have a filter list which have 50 items. I just want to show 5 items and hide the rest to make a "Show More" button.
我有一个包含50个项目的筛选器列表。我只是想显示5个项目并隐藏其余部分来制作“显示更多”按钮。
<ul>
<li ng-repeat="a in filters.area">
<input type="checkbox" ng-change="filter()" ng-model="a.checked"> {{ a.name }}
</li>
</ul>
<span>SHOW MORE</span>
3 个解决方案
#1
#2
2
Use limitTo
filter in AngularJS
在AngularJS中使用limitTo过滤器
{{ limitTo_expression | limitTo : limit : begin}}
{{limitTo_expression | limitTo:limit:begin}}
文档
Something like this for your example:
对于你的例子,这样的事情:
<ul>
<li ng-repeat="a in filters.area | limitTo: 5">
<input type="checkbox" ng-change="filter()" ng-model="a.checked">
{{a.name}}
</li>
</ul>
<span>SHOW MORE</span>
#3
#1
3
You can use the LimitTo
in Angular
您可以在Angular中使用LimitTo
<li ng-repeat="n in numbers | limitTo:numLimit">{{n}}</li>
Here is a sample JsFiddle
这是一个示例JsFiddle
#2
2
Use limitTo
filter in AngularJS
在AngularJS中使用limitTo过滤器
{{ limitTo_expression | limitTo : limit : begin}}
{{limitTo_expression | limitTo:limit:begin}}
文档
Something like this for your example:
对于你的例子,这样的事情:
<ul>
<li ng-repeat="a in filters.area | limitTo: 5">
<input type="checkbox" ng-change="filter()" ng-model="a.checked">
{{a.name}}
</li>
</ul>
<span>SHOW MORE</span>