In Angular 2 I have a component that is clearly a sub-component to another component. For instance, a Contact component within a ContactsPage component. Since the introduction of modules, I must now add ContactComponent to the declaration-section of my NgModule, making the Contact component available in all HTML templates in the module. This gives me two problems:
<contact> outside ContactsPage. I also would like to create very local subcomponents such as <entry> without having to worry about name clashes elsewhere in my app.Is there no way of making a sub-component available only within a specific component? Alternatively, should I make turn every component with sub-components into a module?
You can move Contact and ContactsPage to a ContactsModule NgModule, and then add this module to imports of modules where you want to use ContactsPage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With