2015-09-16 164 views
2

如何列出下拉選項從下面的JSON對象,其中IsDeleted == 0角JS過濾器下拉選項

"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> 
+0

實際上的問題是與分配給作爲貨幣$默認值scope.currencies = {};拋出錯誤和過濾器停止工作..每當在json數組上使用過濾器時,默認值不應該是$ scope.currencies = {}; – user2866086

回答

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

在請將isDeleted:「0」只是替換「:」由 「=」 運算符之後請將isDeleted

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