![]() Though it might be tempting to put all you components in a single module, this is bad for the performance. When I have a component that I don't reuse I won't create a separate module until I need it somewhere else. When I have some components that I use almost everywhere I put them in a single module. ![]() I usually create a new module for every component I reuse. It is hard to tell when you should create new module and when you shouldn't. Next you should import this new module in every module you want to use your component. You should declare and export your component in a new separate module. I also tried putting ContactBoxComponent in CustomersAddComponent and then in another one (from different module) but I got an error saying there are multiple declarations. When the error occurs during unit testing, make sure your declared the component or imported the module in nfigureTestingModule If it is in another module, import that module?.If it is in another module, export the component?.Are you sure the name is correct? (Also check the selector defined in the component).These are the 5 steps I perform when I get such an error. It didin't work so I googled my problem and added ContactBoxComponent to export list as well. I added the ContactBoxComponent import to and put it in declarations list of AppModule. I want to use my ContactBoxComponent inside those components (so inside customers-add-component for example).Īs you can see I created the contacts-box component inside the widgets directory so it's basically inside the AppModule. customers-module) and each module has multiple components (like customers-list-component, customers-add-component and so on). ![]() ![]() I keep my pages in pages directory, where each page is kept in different module (e.g. If 'contacts-box' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the of this component to suppress this message.If 'contacts-box' is an Angular component, then verify that it is part of this module."Uncaught (in promise): Error: Template parse errors: I'm trying to use a component I created inside the AppModule in other modules. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |