如何显示一个消息时,过滤器返回没有什么NG重复 - AngularJS [英] How to show a message when filter returns nothing in ng-repeat - AngularJS

查看:156
本文介绍了如何显示一个消息时,过滤器返回没有什么NG重复 - AngularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个DIV(消息)没有项目的过滤器返回(NG-重复)。

I would like to show one div(message) when no items returned on filter(ng-repeat).

过滤是基于选择框(NG-模型)发生。而没有结果的一些选择选项,那个时候用户应该能够在同一个地方阅读的邮件。
我可以用NG-显示/隐藏在这里?怎么样?

Filter is happening based on select box (ng-model). And there are no results for some select options, at that time user should be able to read a message at same place. Can I use ng-show/hide here? How?

谢谢,

推荐答案

您还可以保存您的过滤数组中的一个变量,然后使用内部的变量 NG-节目前pression:

You can also save your filtered array in a variable and then use that variable inside the ng-show expression:

<select ng-model="shade" ng-options="shade for shade in shades"></select><br>
<ul>
    <li ng-repeat="c in filteredColors = (colors | filter:shade)">{{c.name}}</li>
</ul>
<div ng-show="!filteredColors.length">No colors available</div>

您可以看到它的行动在这个 plunker

You can see it in action in this plunker.

这篇关于如何显示一个消息时,过滤器返回没有什么NG重复 - AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆