溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

select如何在angularjs中使用

發(fā)布時間:2021-03-30 17:22:32 來源:億速云 閱讀:158 作者:Leah 欄目:web開發(fā)

這篇文章將為大家詳細講解有關(guān)select如何在angularjs中使用,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。

1 ng-model="standardCourse.showHours"代替name

2 ng-selected = "1"代替selected="selected",但問題是select下會多出一個無用的option

3 在數(shù)據(jù)準備時設(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",也需要準備數(shù)據(jù)時設(shè)置默認值

準備數(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';
      });

關(guān)于select如何在angularjs中使用就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI