1 ng-model="standardCourse.showHours"代替name
2 ng-selected = "1"代替selected="selected",但問題是select下會多出一個無用的option
3 在數據准備時設置,$scope.standardCourse.showHours= '1';
解決多出的一個無用的option
<label for="_sel_show_hours">是否顯示課時數</label>
<select id="sel_show_hours" ng-model="standardCourse.showHours" >
<option value="1" ng-selected = "1">顯示</option>
<option value="0">不顯示</option>
</select>
radio也是 ng-checked="1",也需要准備數據時設置默認值
准備數據參考
$stateProvider.state('home.standardCourseAdd', {
url: "/standardCourse/add",
templateUrl: "/partials/ace/standardCourse/add.html",
controller: function ($rootScope, $http, $scope, $location, $anchorScroll, $stateParams, $state, $timeout, $compile, Upload) {
fnPost($scope, $state, $http, {'name': ''}, '/standardCourse/toAdd.do', function (success, data) {
$scope.standardCourse = data.entity;
$scope.standardCourse.showHours= '1';
});