angularjs的select使用及默認(rèn)選中設(shè)置
我最近在研究angularjs學(xué)習(xí)的道路上,那么今天也算個學(xué)習(xí)筆記吧!
1 ng-model="standardCourse.showHours"代替name
2 ng-selected = "1"代替selected="selected",但問題是select下會多出一個無用的option
3 在數(shù)據(jù)準(zhǔn)備時設(shè)置,$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",也需要準(zhǔn)備數(shù)據(jù)時設(shè)置默認(rèn)值
準(zhǔn)備數(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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
用angular實現(xiàn)多選按鈕的全選與反選實例代碼
本篇文章主要介紹了用angular實現(xiàn)多選按鈕的全選與反選實例代碼,非常具有實用價值,需要的朋友可以參考下2017-05-05Angular中的結(jié)構(gòu)指令模式及使用詳解
這篇文章主要為大家介紹了Angular中的結(jié)構(gòu)指令模式及使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08AngularJS基礎(chǔ) ng-cloak 指令簡單示例
本文主要介紹AngularJS ng-cloak 指令,這里幫大家整理了ng-clock指令的基礎(chǔ)資料,和簡單的代碼實例及效果圖,學(xué)習(xí)AngularJS指令的朋友可以參考下2016-08-08分享使用AngularJS創(chuàng)建應(yīng)用的5個框架
如果你計劃使用AngularJS創(chuàng)建你的Web應(yīng)用,那現(xiàn)在就開始吧。你不需要有任何的恐懼和擔(dān)心,因為現(xiàn)在有很多的框架都可以很好地支持AngularJS2015-12-12angularjs的select使用及默認(rèn)選中設(shè)置
本篇文章主要介紹了angularjs的select使用及默認(rèn)選中設(shè)置,非常具有實用價值,需要的朋友可以參考下2017-04-04淺析angularJS中的ui-router和ng-grid模塊
下面小編就為大家?guī)硪黄獪\析angularJS中的ui-router和ng-grid模塊。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05