【发布时间】:2019-02-12 11:10:58
【问题描述】:
我在下面有一些与 timzone 相关的 json 数据,我需要将特定的嵌套值绑定到下拉列表中,在使用 angularjs 时,在时区数组中它以字符串格式出现,我需要将它们绑定到下拉列表中。
timezone.json --
{
"countries": {
"US": {
"id": "US",
"name": "United States",
"timezones": [
"America/New_York",
"America/Detroit",
]
},
"CA": {
"id": "CA",
"name": "Canada",
"timezones": [
"America/St_Johns",
"America/Halifax",
]
},
"IN": {
"id": "IN",
"name": "India",
"timezones": [
"Asia/Kolkata"
]
},
}
}
脚本--
$http({
method: "GET",
url: 'timezon.json'
}).then(function mySuccess(response) {
$scope.timeZones = response.data;
}, function myError(response) {
$scope.timeZones = response.statusText;
});
HTML 内容
<select class="form-control">
<option value="0">--Select Time Zones></option>
</select>
【问题讨论】:
标签: javascript jquery html angularjs