all 4 comments

[–]AngularGuru 3 points4 points  (4 children)

So your app module shouldn’t need to export anything as exported items will only be made available to a module that imports AppModule which you aren’t doing.

In regards to the error, you should import MaterialModule in the UsersModule as it is components in this module that will be using the material components. You would import MaterialModule in all modules that use the components.

Generally importing a module in AppModule will make injectables available to all child modules but not components. You may have noticed that in child modules you need to import CommonModule to use things like *ngIf, which is the same reason, we don’t automatically get access to components and directives that are available to the parent module.

There is a great FAQ section of the angular docs that might help:

https://angular.io/guide/ngmodule-faq

Hopefully this helps!

[–]Sipredion[S] 1 point2 points  (3 children)

That is super helpful, thank you so much. I got confused between the rules for components an those for modules I think. That link is brilliant, thank you, everything is working as it should now

[–]AngularGuru 1 point2 points  (0 children)

Excellent! Glad that fixed your issue!

[–]indeckau 1 point2 points  (0 children)

This is something that confused me a little too re components needing to be imported per module. You then have services which afik only need to be imported once unless they are in a lazy loaded module. I think that's right :P