angularjs的select使用及默認選中設置
我最近在研究angularjs學習的道路上,那么今天也算個學習筆記吧!
1 ng-model="standardCourse.showHours"代替name
2 ng-selected = "1"代替selected="selected",但問題是select下會多出一個無用的option
3 在數(shù)據(jù)準備時設置,$scope.standardCourse.showHours= '1';
解決多出的一個無用的option
<label for="_sel_show_hours">是否顯示課時數(shù)</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",也需要準備數(shù)據(jù)時設置默認值
準備數(shù)據(jù)參考
$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'; });
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
用angular實現(xiàn)多選按鈕的全選與反選實例代碼
本篇文章主要介紹了用angular實現(xiàn)多選按鈕的全選與反選實例代碼,非常具有實用價值,需要的朋友可以參考下2017-05-05分享使用AngularJS創(chuàng)建應用的5個框架
如果你計劃使用AngularJS創(chuàng)建你的Web應用,那現(xiàn)在就開始吧。你不需要有任何的恐懼和擔心,因為現(xiàn)在有很多的框架都可以很好地支持AngularJS2015-12-12淺析angularJS中的ui-router和ng-grid模塊
下面小編就為大家?guī)硪黄獪\析angularJS中的ui-router和ng-grid模塊。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05