Angular ng-option 过滤器 return 全部除外
Angular ng-option filter return all except
我有一个来自外部插件的国家列表,这里是一小段摘录:
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 国家
<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>
现在我想在 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>
有关详细信息,请参阅
我有一个来自外部插件的国家列表,这里是一小段摘录:
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 国家
<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>
现在我想在 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>
有关详细信息,请参阅