【发布时间】:2017-01-18 04:34:46
【问题描述】:
这是我的 HTML 代码
<body ng-app="mainApp">
<div ng-controller="myController">
<select>
<option ng-repeat="person in persons">{{ person.data }}</option>
</select>
</div>
</body>
这是我的 JavaScript 代码
var app = angular.module("mainApp", []);
app.controller("myController", function($scope, $http) {
$http.get("JSON URL")
.success(function(response) {
$scope.persons = response.data;
});
});
我的 JSON URL 是这种格式[{"status": "success", "data": ["bank1","bank2","bank3"]}],我只想要下拉列表中的“数据”列表,JSON 数据中的银行太多,如何使用 select 和 option?
【问题讨论】:
-
你试过像this这样使用`ng-options'
-
考虑使用
ng-options指令。有关详细信息,请参阅AngularJS ng-options Directive API Reference。
标签: javascript angularjs json