refactor(app): refactor forRoot & menu import

This commit is contained in:
Dmitry Nehaychik 2017-07-20 15:14:38 +03:00
parent d6cef06dcd
commit be69ccc058
6 changed files with 170 additions and 111 deletions

View file

@ -1,7 +1,12 @@
import { NgModule, Optional, SkipSelf } from '@angular/core';
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
import { CommonModule } from '@angular/common';
import { throwIfAlreadyLoaded } from './module-import-guard';
import { DataModule } from './data/data.module';
const NGA_CORE_PROVIDERS = [
...DataModule.forRoot().providers,
];
@NgModule({
imports: [
@ -13,4 +18,13 @@ export class CoreModule {
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
throwIfAlreadyLoaded(parentModule, 'CoreModule');
}
static forRoot(): ModuleWithProviders {
return <ModuleWithProviders>{
ngModule: CoreModule,
providers: [
...NGA_CORE_PROVIDERS,
],
};
}
}