第一種<select name="editRole" ng-model="editRole" class="form-control selectForm" ng-options="role.id as role.roleName for role in roleList"></select>在controller設置$scope.editRole,但是ng-options默認的值沒有。第二種:但在這種情況下可以的<select name="editRole" ng-model="editRole" class="form-control selectForm" ng-options="role.roleName for role in roleList"></select>因為需要獲取value,所以采用第一種方案,但這種方案沒法默認選中值。求原因謝謝。
angularjs 設置ng-options 的默認值
ibeautiful
2018-12-01 14:15:54