Wednesday, April 25, 2018

Error component defined in multiple module.(Share component in multiple modules) in Angular 2

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

Jquery Select and Change selector and event .How to Post data using jquery to mvc and web api action methods

Jquery :Change event in Jquery Method: Demo     $("#drpCountry").change(function () {             var id = $("#DrpCoun...