简体   繁体   English

angularjs ng-repeat:仅显示匹配结果的列表

[英]angularjs ng-repeat : only show a list off matched results

At the moment i have a ng repeat, that repeat a set of results. 目前我有重复,重复一组结果。

<a class="list-group-item" href="#trip/{{trip.id}}/overview" ng-repeat="trip in trips | filter:search | limitTo:-15">

Basicly my list shrinks the more i enter stuff in my input field 基本上我的列表缩小了我在输入字段中输入的内容越多

<input type="text" ng-model="search.$" class="form-control input-lg">

What i want to achieve is that i have a result set of 0 items at start. 我想要实现的是我在开始时有一个0项的结果集。 end the more i type into the ng-model input field the more or less items matched show up. 结束我输入的ng-model输入字段越多,匹配的项目就会越多或越少。

is there a filter for that or something to achieve my goal? 是否有过滤器可以实现我的目标?

thx 谢谢

要么你编写处理特殊情况下,当一个新的过滤服务search.$空的,或者你也许可以做这样的事情(未经测试):

<a ... ng-repeat="trip in (search.$ ? (trips | filter:search | limitTo:-15) : [])">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM