Angularjs 用角度值填充下拉列表时出错

Angularjs 用角度值填充下拉列表时出错,angularjs,angularjs-directive,angularjs-scope,angularjs-ng-repeat,Angularjs,Angularjs Directive,Angularjs Scope,Angularjs Ng Repeat,当我的页面加载时,我会像这样预先设置下拉列表 $scope.categories = [ 0, 1, 2, 3, 4 ]; 这是我的下拉列表 <div>

当我的页面加载时,我会像这样预先设置下拉列表

 $scope.categories =
                    [
                        0,
                        1,
                        2,
                        3,
                        4
                    ];
这是我的下拉列表

<div>
                        Category:
                        <select data-ng-model="category.currentCategory"
                                data-ng-options="cat for cat in categories">{{cat}}
                        </select>
                    </div>

对于数据ng模型,您应该只有“category”(从不在category上定义currentCategory属性),并且应该将其设置为$scope.category=1,因为这是模型,而不是$scope.cat。当您说“cat代表类别中的cat”时,cat是一个局部变量,表示选项中类别的迭代。

尝试以下操作:

<select ng-model="Caty">
   <option ng-repeat="cat in categories">
      {{cat}}
   </option>
</select>
它起作用了

<select ng-model="Caty">
   <option ng-repeat="cat in categories">
      {{cat}}
   </option>
</select>
$scope.Caty = $scope.categories[0];