2014-10-31 46 views
0

這是我的json [[「A」,「aaa」],[「B」,「bbb」],[「C」,「ccc」]] 這裏的數據'當選擇數據時,應在下拉菜單中顯示「aaa','bbb'和'ccc',其相應的值即'A','B'或'C'應填充到另一變量如何使用ngSelect for JSON

回答

1

像這樣:

<select ng-model="yourModel" 
     ng-options="val[0] as val[1] for val in testData"> 
</select> 

Example

+1

正是我所需要的... ty兄弟... @ Josep – 2014-10-31 13:52:48

0

我有這樣的選擇:

%select{"ng-model" => "recipeDifficulty", "ng-options" => "d.description for d in difficulties"} 

當我選擇一個,然後點擊一個按鈕,在我的控制器我把它添加到JSON:

recipe = { ... 'difficulty_id': $scope.recipeDifficulty.id, ... } 

我從一個數據庫表中的值有兩個字段:「ID」和'description'