1
我希望能够从两个地方设置任何控件的禁用属性。在控制本身上,基于视图本身硬编码的规则。并根据基于外部服务中定义的规则的指令。Angular指令设置禁用的属性
当指令设为禁用为true时,不应该被控件上定义的内容覆盖。但是,当指令设置为禁用为false时,则应该触发控件上定义的内容。
我希望它是有道理的。到目前为止,我有这个代码,但它不能按我想要的方式工作。
<input check-edit-matrix type="checkbox"
data-ng-model="model.isPrivate"
ng-disabled="model.isDeleted || model.isConfidential" />
(function() {
'use strict';
var directiveId = 'checkEditMatrix';
angular.module('common.directives')
.directive(directiveId, ['dataService', directiveFunc]);
function directiveFunc(dataService) {
return {
restrict: 'A',
scope: {
},
link: function (scope, element, attrs) {
attrs['disabled'] = 'disabled';
//if (attrs['disabled'] === 'disabled') {
// alert('already disabled !')
//}
}
};
}
})();