我最近在研究angularjs學習的道路上,那么今天也算個學習筆記吧!
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'; });
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。
新聞熱點
疑難解答