在分页中,我提供了下拉选项,用于选择每页上显示的项目数。但是选择未显示控制器中设置的默认值。
请参阅http://plnkr.co/edit/bqLKGB2nBK6m53XJ1U85?p=preview
<select name="singleSelect" ng-model="pageSize">
<option value="10" selected>10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="50">50</option>
<option value="100">100</option>
答案 0 :(得分:2)
尝试ng-value
:
<select name="singleSelect" ng-model="pageSize">
<option ng-value="10">10</option>
<option ng-value="20">20</option>
<option ng-value="30">30</option>
<option ng-value="50">50</option>
<option ng-value="100">100</option>
</select>
或修改此行而不应用ng-value
:
$scope.pageSize = '10';
答案 1 :(得分:1)
angular
.module('test', [])
.run(function TestCtrl($rootScope) {
$rootScope.sizes = [
10, 11, 12, 13, 14, 15
];
$rootScope.size = $rootScope.sizes[0];
})
;
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<section ng-app="test">
<h1> Size is: <code ng-bind="size"></code></h1>
<select
ng-model="size"
ng-options="s for s in sizes">
</select>
</section>
&#13;