Angular js过滤基于某个常量值的下拉选项

时间:2015-09-16 06:52:38

标签: javascript angularjs

如何从Json对象下面列出IsDeleted == 0

的下拉选项
"currencies":[{
    "CurrencyID":"1",
    "CurrencyCode":"AED",
    "CurrencyName":"United Arab Emirates Dirham",
    "IsDeleted":"1"
},{
    "CurrencyID":"2",
    "CurrencyCode":"AFN",
    "CurrencyName":"Afghan Afghani",
    "IsDeleted":"1"
},{
    "CurrencyID":"3",
    "CurrencyCode":"ALL",
    "CurrencyName":"Albanian Lek",
    "IsDeleted":"1"
}];


<select ng-model="data.CurrencyID" ng-options="cu.CurrencyID as cu.CurrencyName for cu in currencies | filter : IsDeleted :'0'"></select>

2 个答案:

答案 0 :(得分:2)

<select ng-model="data.CurrencyID" ng-options="cu.CurrencyID as cu.CurrencyName for cu in currencies |filter : {IsDeleted :'0'}"></select>

答案 1 :(得分:0)

在IsDeleted:'0'中,只需在isDeleted后用“=”运算符替换“:”

<select ng-model="data.CurrencyID" ng-options="cu.CurrencyID as cu.CurrencyName for cu in currencies | filter : IsDeleted = '0'"></select>