0

I know I can override a directive in the following way:

angular.module('3th-party-module')
     .directive('3th-party-directive', my3rdPartyDirective)

However I would like to override the behavior of the form directive. I thought doing:

angular.module('ng')
     .directive('form', myFormDirective)

But it's not working. I get the following error:

Failed to instantiate module ng due to: Error: [$injector:unpr] Unknown provider: $compileProvider

Is there a way to do this?

The reason I want this is because errors propagate by default to the parent form, and I don't want this behavior because it disables my submit buttons.

raichu
  • 688
  • 2
  • 8
  • 15
  • 1
    You will probably be better off asking for specifics on your actual issue of preventing 'errors propagate by default to the parent form'. See http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem – Matthew Green Feb 02 '17 at 16:46
  • Overriding `form` is a terrible idea by all means. This is XY problem, as it was already said. – Estus Flask Feb 02 '17 at 17:29
  • Can you explain why this is a bad idea? There is already a question on how to prevent errors from propagating to the parent form. The answer to it was that there was no solution. (http://stackoverflow.com/questions/19333544/skip-nested-forms-validation-with-angularjs) That's why I thought I had to override the form directive. – raichu Feb 02 '17 at 17:37
  • This will screw up all directives that rely on `form` directive (and there may be a lot of them, including `ng-model`, because it is *core*). There may be other ways to get around your problem with forms. They wouldn't call it XY problem for nothing. You can try to re-ask the question and provide all necessary details that reflect your situation. Btw, you need to address users with @ in comments, otherwise they won't get a notification. – Estus Flask Feb 02 '17 at 18:09

0 Answers0