import { ModuleWithProviders, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { BzThemeService } from './theme.service'; import { BzThemeConfig, THEME_CONFIG } from './theme.config'; @NgModule({ declarations: [], imports: [ CommonModule ] }) export class BzThemeModule { static forChild(theme?: BzThemeConfig): ModuleWithProviders { return BzThemeModule._setProvider(theme); } static forRoot(theme?: BzThemeConfig): ModuleWithProviders { return BzThemeModule._setProvider(theme); } /** * Set provider. * * @author Federico Gambardella * @param {BzThemeConfig} config */ static _setProvider(theme?: BzThemeConfig): ModuleWithProviders { return { ngModule: BzThemeModule, providers: [BzThemeService, { provide: THEME_CONFIG, useValue: theme }] }; } }