0

I have this directive which avoids an input to be marked as $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;
          }
        };
      });
})();

and this other one, which defines a custom widget, <workflow-input>:

(function () {
  'use strict';

  angular
    .module('app.widgets')
    .directive('workflowInput', workflowInput)
    .controller('WorkflowInputController', WorkflowInputController);

  /* @ngInject */
  function workflowInput() {
    return {
      restrict: 'E',
      scope: {
        selectedWorkflow: '=ngModel'
      },
      controller: WorkflowInputController,
      controllerAs: 'vm',
      templateUrl: '/client/app/widgets/workflowInput.html'
    };
  }
...
})();

I want to use it as this:

<workflow-input ng-model="vm.asset.workflows" no-dirty-check></workflow-input>

I understand that the noDirtyCheck directive is incomplete, since it's not being applied directly on the actual <input> and it needs to be fixed, but that's not the issue at hand, the problem is that the noDirtyCheck directive is never being called. I put a breakpoint on the workflowInput controller and I can see the directive is not listed in the element's controllerDirectives in nodeLinkFn (in angular's codebase). There's only ngModel and workflowInput there.

Anyone knows why this might be happening? Thank you

2
  • 1
    It should work so there must be something else going on. Can you provide a minimal reproducible example demonstrating the issue? Are you certain that you've injected your blocks.noDirtyCheck module?
    – Lex
    Commented May 5, 2017 at 23:15
  • you're right, I forgot injecting it. Sorry Commented May 8, 2017 at 15:32

1 Answer 1

0

I forgot injecting the module into the application. Thank you @Lex

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.