我有一个特定的情况,我在手风琴中重复我的数据,我需要的是当过滤器(搜索框)在ng-repeat="sport in sports"
上没有返回任何内容时向用户显示一条消息
<input ng-model="query" placeholder="Search sports...">
<accordion close-others="false">
<accordion-group ng-repeat="sport in sports | filter:query"
ng-show="sport.leagues.length">
<accordion-heading>
<div ng-click="addSportToLines(sport);">
{{::sport.name}}
</div>
</accordion-heading>
<div class="list-group leagues-margin">
<a href="javascript:void(0);" class="list-group-item"
ng-repeat="league in sport.leagues"
ng-class="{active: league.active}"
ng-click="addLeagueToLines(league)">{{::league.name}}
</a>
</div>
</accordion-group>
</accordion>
答案 0 :(得分:2)
试试这个,
<div ng-show="!(sports | filter:query).length">No items</div>
或者,我们可以通过将过滤结果分配给另一个变量(如下所示)来消除一个过滤器,
<accordion close-others="false">
<accordion-group ng-repeat="sport in filteredSports = (sports | filter: query)"
ng-show="sport.leagues.length">
<accordion-heading>
...
</accordion-group>
</accordion>
<div ng-show="!filteredSports.length">No items</div>
感谢。