我有一个网络服务,其结果如下:
{
"selectedStateId": "1",
"selectedCityId": "1",
"selectedAreaId": "1",
"states": [{
"stateId": "1",
"stateName": "Gujarat"
}, {
"stateId": "2",
"stateName": "Rajasthan"
}],
"cities": [{
"cityId": "1",
"stateId": "1",
"cityName": "Ahmedabad"
}, {
"cityId": "2",
"stateId": "1",
"cityName": "Surat"
}],
"areas": [{
"areaId": "1",
"cityId": "1",
"areaName": "thaltej"
}, {
"areaId": "2",
"cityId": "1",
"areaName": "Maninagar"
}, {
"areaId": "3",
"cityId": "1",
"areaName": "Naranpura"
}]
}
现在,我想将州、城市和地区的数组绑定(bind)到三个不同的 select
并使用作为父对象成员的 stateId、cityId 和 areaId 设置其值。
两个问题:
- 如何设置三个不同
select
的值? - 如果我们有对象数组(我在上面创建的数组),我们如何实现 (1)?
谢谢。
编辑:我想前两个答案有一些误解。所以,改变了我的数据表示。我想将 selectedStateId
设置为 states 的 select
元素,将 selectedCityId
设置为 select
元素城市等等..现在,我想你应该清楚我的要求了..
最佳答案
我在这里为你创建了一个plunker。请用具有 3 个选择的 html 来查看它
<select>....</select>
关于javascript - Angular js : set option value after filling options in select,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30682101/