第二个AngularJS指令未从html属性加载
我有这个指令,它避免将输入标记为第二个AngularJS指令未从html属性加载,angularjs,angularjs-directive,angular-directive,Angularjs,Angularjs Directive,Angular Directive,我有这个指令,它避免将输入标记为$pristine: (function () { 'use strict'; angular .module('blocks.noDirtyCheck', []) .directive('noDirtyCheck', function() { // Interacting with input elements having this directive won't cause the // for
$pristine
:
(function () {
'use strict';
angular
.module('blocks.noDirtyCheck', [])
.directive('noDirtyCheck', function() {
// Interacting with input elements having this directive won't cause the
// form to be marked dirty.
return {
restrict: 'A',
//require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
ctrl.$pristine = false;
}
};
});
})();
另一个定义了一个自定义小部件,
:
我想这样使用它:
<workflow-input ng-model="vm.asset.workflows" no-dirty-check></workflow-input>
我知道,noDirtyCheck
指令是不完整的,因为它没有直接应用于实际的
,需要修复,但这不是当前的问题,问题是,noDirtyCheck
指令从未被调用。我在workflowInput
控制器上放置了一个断点,我可以看到该指令未列在NodeLink
中元素的controllerDirectives
中(在angular的代码库中)。那里只有ngModel
和workflowInput
有人知道为什么会这样吗?谢谢我忘了将模块注入应用程序。谢谢@Lex它应该会起作用,所以肯定还有别的事情发生。你能就这个问题提供一个例子吗?你确定你已经注入了
块。noDirtyCheck
模块吗?你是对的,我忘记注入了。很抱歉
<workflow-input ng-model="vm.asset.workflows" no-dirty-check></workflow-input>