// angular import { NgModule, ModuleWithProviders, Optional, SkipSelf } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; import { HttpModule } from '@angular/http'; // module import { CORE_DIRECTIVES } from './directives/index'; import { CORE_PROVIDERS } from './services/index'; import { Config } from './utils/index'; interface ICoreModuleOptions { window?: any; console?: any; } /** * Do not specify providers for modules that might be imported by a lazy loaded module. */ @NgModule({ imports: [ CommonModule, RouterModule, HttpModule ], declarations: [ CORE_DIRECTIVES ], exports: [ CommonModule, FormsModule, RouterModule, HttpModule, CORE_DIRECTIVES ], providers: [ CORE_PROVIDERS ] }) export class CoreModule { // configuredProviders: *required to configure WindowService and ConsoleService per platform static forRoot(configuredProviders: Array): ModuleWithProviders { return { ngModule: CoreModule, providers: configuredProviders }; } constructor(@Optional() @SkipSelf() parentModule: CoreModule) { if (parentModule) { throw new Error('CoreModule already loaded; Import in root module only.'); } } }