【发布时间】:2016-02-20 01:12:09
【问题描述】:
我可以在复选框中使用 ng-readonly 指令吗?
即使在使用 ng-readonly 修饰后,复选框也是可写的。
HTML:
<input type="checkbox" ng-model="model" ng-readonly="test" /> {{model}}
控制器:
myApp.controller('MyCtrl', function($scope) {
$scope.test = true;
});
已添加Fiddle
【问题讨论】:
-
将 ng-model 添加到您的输入字段
-
显然 ng-readonly 不适用于复选框,您可以使用ng-disabled