AngularJS:过滤没有特定值的 ng-options [英] AngularJS: Filter ng-options not having specific values
本文介绍了AngularJS:过滤没有特定值的 ng-options的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想像这样过滤一个选择:
I want to filter on a select like so :
<select ng-model="test" ng-options="c as c.label group by c.type for c in columns
| filter:{c.type:'!field'} | filter:{c.type:'!map'}"></select>
添加列模型:
Columns = [
{
name: "name",
label: "Label",
info: "Information displayed in help",
type: "type",
view: "html template",
style: "min-width: 10em;",
show: true
},
{
...
}
];
列用于多种用途并优化我的代码我需要它也在选择中,但没有类型为字段"或地图"的条目
Columns is used for several things and to optimize my code I need it to be also in a Select, but without the entries whose type are 'field' nor 'map'
然而,我可以从所有内容中进行选择,甚至是字段"和地图"类型的条目.有没有干净的方法来做到这一点?
Yet, I get to choose from everything, even the entries which types are 'field' and 'map'. Is there a clean way to do it ?
推荐答案
AngularJS NOT Filter
<select ng-model="test" ng-options="c as c.label group by c.type for c in columns
| filter:{ type : '!field' }
| filter:{ type : '!map' }">
</select>
来自文档:
From the docs:
"...可以通过在字符串前加上 ! 来否定谓词."
"模式对象可用于过滤数组包含的对象的特定属性.例如,{name:M", phone:1"} 谓词将返回具有包含M"的属性名称的项的数组.和财产电话包含1"...
这篇关于AngularJS:过滤没有特定值的 ng-options的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文