angular 2 - Problem when calling directive

Asked

Viewed 199 times

0

Good afternoon, you guys....

angular

I would like your help if possible.

I’m having trouble using a directive. We created a directive in a directive directory, (app> Directive) but within my form I am unable to use it. We have 2 directories (company and subsidiary) only company can use the resource of this directive. No error in the module company.module or affiliate.module, but it spits out an error in the console and does not load the page.

This is the mistake: Compiler.js:485 Uncaught Error: Type Istmaskdirective is part of the declarations of 2 modules: Empresamodule and Filialmodule! Please consider Moving Istmaskdirective to a Higher module that Imports Empresamodule and Filialmodule. You can also create a new Ngmodule that Exports and includes Istmaskdirective then import that Ngmodule in Empresamodule and Filialmodule.

  • The directive stops working when we have a few more directories inside. Ex: Stayed in these Directive: app directories> Directive> myDirectionCnpj. File that calls the directive was in: app> affiliate> affiliate-form. But the funny thing is that when I use the directive in the directory: app> affiliate it works and I can use in affiliate and company, for example

1 answer

0

Most likely your problem has already been solved, but I’ll leave the answer to others who go through the same problem.

A directive can only be declared in one module. This error message means that you have declared it in two modules. The same goes for components. A suggested solution would be: declare your directive in a specific module, and export it in it. In the components where you want to use it, open the module where they are declared and import the module where the directive was exported.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.