我有这样的代码:
<form ng-controller="MyCtrl" ng-submit="save()>
<div ng-repeat="f in fields">
<label for="theInput">{{ f.label }}</label>
<select ng-model="f.value" ng-init="f.value = f.id" ng-options="item.id as item.name for item in f.items"></select>
</div>
</form>
<script>
var Mod = angular.module('myApp', []);
function MyCtrl($scope, $http) {
var categories = [];
$http.get(BASE_URL + 'task/listCategory').success(function(data) {
categories = data;
});
$scope.fields = [
{ label: 'Category', value: 'items', items: categories }
];
}
</script>
为什么角度选择不像魅力? 谢谢你的帮助
答案 0 :(得分:0)
var Mod = angular.module('myApp', []);
function MyCtrl($scope, $http) {
var categories = [];
$http.get(BASE_URL + 'task/listCategory').success(function(data) {
categories = data;
$scope.fields = [{ label: 'Category', value: 'items', items: categories }];
});
}