Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
第二个AngularJS指令未从html属性加载_Angularjs_Angularjs Directive_Angular Directive - Fatal编程技术网

第二个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>