2014-10-10 214 views
1

不可見我有這樣angularjs選擇的項目在下拉

listItems = [ 
    { "id": 1, "name": "myname1" }, 
    { "id": 2, "name": "myname2" }, 
    { "id": 3, "name": "myname3" } 
]; 

一個複雜的對象,我想創建從上方時listItems選項這樣

<select> 
    <option value="1">myname1</option> 
    <option value="2">myname2</option> 
    <option value="3">myname3</option> 
</select> 

我已經使用這個angularjs代碼,其生成正確的HTML代碼,但無論我在下拉列表中選擇什麼都沒有顯示在選擇框內

<select ng-model="iList" ng-options="item.id as item.name for item in listItems track by item.id" /> 

回答

1

假設listItems$scope

<select ng-options="item.id as item.name for item in listItems"></select> 
+0

thx。我還需要ng-model屬性 – FarazShuja 2014-10-10 12:29:26