How to make the ngIf directive globally visible in all projects?
1 answer
Import BrowserModuleinto the root module and CommonModuleinto other modules where you want to use common directives.
@NgModule({
imports: [BrowserModule],
...
})
class AppModule {}
and
@NgModule({
imports: [CommonModule],
// Now MyComponent has access to ngIf
declarations: [MyComponent]
...
})
class OtherModule {}
BrowserModuleexports CommonModule, so there is no need to import CommonModuledirectly into the root module.
+5