繁体   English   中英

如何在下拉列表中使用ng-class

[英]How to use ng-class within a dropdownlist

我不熟悉AngularJS中的ng-class,我需要知道如何在选择选项后禁用AngularJS中的选择列表,而在未选择任何选项的情况下启用它。不为空则禁用选择列表。 这是我尝试过的方法,但是没有用

的HTML

<select class="categories" ng-class="{'disabled':Model.CurrentDowntime.CategoryId !== 0}"  ng-model="Model.CurrentDowntime.CategoryId" ng-options="downtimeCategory.CategoryId as downtimeCategory.CategoryName for downtimeCategory in Model.DowntimeCategories">
</select>

JS

angular.module('myApp', [])

 .controller('DowntimeController', function ($scope, $http) {
     $scope.Model = new Model($http);
     $scope.Model.CurrentDowntime = {};   
});

disabled是属性,而不是类。 使用ng-disabled

<select class="categories"
        ng-disabled="Model.CurrentDowntime.CategoryId !== undefined"
        ng-model="Model.CurrentDowntime.CategoryId"
        ng-options="downtimeCategory.CategoryId as downtimeCategory.CategoryName for downtimeCategory in Model.DowntimeCategories">
</select>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM