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