Skip to content

Using NgIconsModule in SharedModules #79

Closed Answered by ashley-hunter
RobertoHixsa asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, sure, so as you discovered you cannot export them from an NgModule, the reason for that is that NgModules can only export components. Our icons are not components but instead are strings that are registered in Angular's dependency injection system. With the way the DI system works this makes icons available to any child components (or lazy loaded modules) without any need to export.

To make icons available to your entire application you can either register them in the AppModule:

@NgModule({
    imports: [NgIconsModule.withIcons(MaterialIcons)]
})
export AppModule {}

Or have a CoreModule that your AppModule imports. This module typically contains anything that registers things with the…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@RobertoHixsa
Comment options

@ashley-hunter
Comment options

Answer selected by RobertoHixsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants