-1

我有这样的代码:

<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>

为什么角度选择不能像魅力一样工作?感谢您的帮助

4

1 回答 1

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 }];
        });
    }
于 2013-11-04T06:54:44.313 回答