// angular import { NgModule, Optional, SkipSelf, NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; import { RouterModule } from '@angular/router'; // app import { SAMPLE_COMPONENTS } from './components/index'; import { SAMPLE_PROVIDERS } from './services/index'; import { MultilingualModule } from '../i18n/multilingual.module'; /** * Do not specify providers for modules that might be imported by a lazy loaded module. */ @NgModule({ imports: [ CommonModule, FormsModule, HttpModule, RouterModule, MultilingualModule, ], declarations: [ SAMPLE_COMPONENTS ], providers: [ SAMPLE_PROVIDERS ], schemas: [ NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA ], exports: [ SAMPLE_COMPONENTS, MultilingualModule ] }) export class SampleModule { constructor(@Optional() @SkipSelf() parentModule: SampleModule) { if (parentModule) { throw new Error('SampleModule already loaded; Import in root module only.'); } } }