javascript - Angular ng-option 过滤器返回除
问题描述
我有一个来自外部插件的国家/地区列表,这里是一小段摘录:
angular.module('maha.countries').config(['CountriesProvider',
function(CountriesProvider) {
CountriesProvider.setCountriesList({
"AF": "Afghanistan",
"AX": "Alandinseln",
"AL": "Albanien",
"DZ": "Algerien",
"UM": "Amerikanisch-Ozeanien",
"AS": "Amerikanisch-Samoa",
});
}])
})
我对这些国家有一个选择
<select class="form-control"
ng-options="country[0] as country[1] for country in countries"
id="country" name="country">
<option translate>
please_choose
</option>
</select>
现在我想在选择中显示除阿尔及利亚以外的所有国家,例如,我该怎么做?
我尝试使用filter:country='DZ'
,但这仅显示阿尔及利亚,但是,我需要显示所有这些,而不是阿尔及利亚。
解决方案
假设country[0]
是两个字母的国家代码,使用:
<select class="form-control"
ng-options="country[0] as country[1] for country in countries
| filter : {'0': '!DZ'} "
id="country" name="country">
<option translate>
please_choose
</option>
</select>
有关详细信息,请参阅
推荐阅读
- wordpress - 无限循环 Wordpress 301 重定向 AWS CloudFront 负载均衡器和 LightSail
- android - 无法在线性布局中插入按钮
- ruby - 返回参数的名称而不是其值 - Ruby
- javascript - 如何渲染到 webRTC 发送的 dom 图像
- javascript - 坚持使用自定义过滤器获取实时数据的方法
- python - 如何实现信号处理?
- c# - C# 如何从 2nd Form 以 1st Form 创建对象
- python - 一起移动两个窗口tkinter
- excel - 返回基于多个范围的结果?
- python - scrapy 规则遵循网站上的所有页面