itsphilz
itsphilz

Reputation: 455

Angular 2 - App Module declaration of Upgraded AngularJS component not working

Gist

I have an application running AngularJS and Angular side by side, using the UpgradeModule. I have "upgraded" and AngularJS component (angular.component) for use in our Angular components (@Component). I have done so using the instructions on the Angular 1.x upgrade page.

The issue is that when this "upgraded" component is declared in the AppModule declarations: [] array, I receive an error saying unknown element 'tooltip'.

When I remove the declaration from the AppModule and declare it instead in the @NgModule for the component in which the upgraded component will be used, it works fine.

Please review the Gist for the code that is being used.

Upvotes: 0

Views: 145

Answers (1)

Santanu Biswas
Santanu Biswas

Reputation: 4787

There is nothing wrong with the behavior.

  • The components must be declared in the module where you want to use it.

  • If you want to use the component in multiple modules, Create a SharedModule (shared module) and add your component to it's declarations and exports.

  • Import the SharedModule in other modules wherever you want to use this component.

More about shared modules in Angular2 Docs.

And here is a nice tutorial on NgModules that might help you.

Upvotes: 1

Related Questions