我想從json對象顯示國家名稱。 json數據查看數組對象的集合,該對象使用ng-repeat迭代該json數據並顯示到選擇框中。我嘗試了以下的代碼。如何在角js中使用Array對象json創建選擇框?
Json
----
$scope.countries = [
{
"AT": "Austria"
},
{
"CI": "Côte d'Ivoire"
},
{
"CG": "Congo"
},
{
"SV": "El Salvador"
},
{
"IN": "India"
},
{
"SX": "Sint Maarten (Dutch part)"
},
{
"SZ": "Swaziland"
},
{
"CH": "Switzerland"
},
{
"AE": "United Arab Emirates"
}
]
html
----
<select ng-model="counryNames" >
<option ng-repeat="(key,country) in countries" value="{{key}}">{{country[key]}}</option>
</select>
是什麼問題? – Sajeetharan
選擇框空我更新jsfiddle請檢查一次http://jsfiddle.net/HB7LU/29324/ –
檢查答案 – Sajeetharan