Angular 2 global component

蹲街弑〆低调 提交于 2019-12-06 07:31:53

I'd assume "global components" are not known in the angular 2 architecture. See also here ==> https://angular.io/docs/ts/latest/guide/architecture.html

From experience I know that it can be a problem if components (e.g. pipes) are imported at the app.module level. When doing this with a pipe for example you get a "pipe not found" error. Maybe you encounter a similiar problem with your component.

So I'd recommend to make your component part of a module and then import your module in your app.module instead of the component.

One thing you can do to easily use components in different modules is to create a module for your component(s) and declare your component(s) in that module, then whenever you want to use the component(s), just import that module in the module you want to use the component(s).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!