Error component defined in multiple module or Share component in multiple modules in Angular 2
Share Module—In this we define the component we want to
share among other modules.
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { ShareComponent } from '../Component/Share.component';
@NgModule({
imports: [CommonModule,
FormsModule
],
declarations: [
ShareComponent
],
exports: [ShareComponent
]
})
export class SharedModule
{
}
Call above SharedModule defined in another Modules
import { SharedModule } from '../Modules/Shared.module';
import {EmployeeComponent} from '../Component/Employee.component';
@NgModule({
declarations: [
EmployeeComponent
],
imports: [FormsModule,
HttpModule,
CommonModule,
routing,
SharedModule
],
entryComponents: [
],
providers: [
{ provide: APP_BASE_HREF, useValue: '/' },
],
bootstrap: [
EmployeeComponent ]
})
export class EmployeeModule
{
}
No comments:
Post a Comment