sp_conway
sp_conway

Reputation: 107

Can feature module use component declared in app.module.ts

I have a component that is declared in app.module.ts. It is in the declarations array. I also have a feature module. I'm trying to use the component that was declared in app.module.ts in my feature module but am getting some errors related to no value accessor for form control.

When I take the component that is declared in app.module.ts and put it in a shared module and import the shared module to my feature module, everything works fine.

The simple solution is probably to take all my shared components and put them into a shared module, however I am wondering if there is a way for me to not have to do that. I understand it may be a best practice but I would like to know if there is a way to have a component declared in app.module.ts and used in a feature module without having the component in its own shared module.

Upvotes: 0

Views: 869

Answers (1)

As you said the only way you could do that is using a shared module. Something you can do to not use a shared module is to export this component in app module and then import app module to your feature module. Or you should also work with the routing module, importing your component and make it works.

Upvotes: 2

Related Questions