Answers for "declare component in multiple modules"

0

declare component in multiple modules

//Create a SharedModule:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

@NgModule({
    imports: [
        CommonModule
     ],
    declarations: [
        SharedComponent
    ],
    exports: [
        SharedComponent
    ]
})
export class SharedModule {}

//and import it in the module you need:
@NgModule({
    imports: [SharedModule]
})

//and in the appModule:
@NgModule({
    imports: [ChildModule, SharedModule],...
})
Posted by: Guest on September-15-2021

Code answers related to "declare component in multiple modules"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language