|
1 | 1 | import {ModuleWithProviders, NgModule} from '@angular/core'; |
2 | | -import {BusyConfig, DefaultBusyComponent} from './model/busy-config'; |
| 2 | +import {BUSY_CONFIG_DEFAULTS, BusyConfig, DefaultBusyComponent, IBusyConfig} from './model/busy-config'; |
3 | 3 | import {CommonModule} from '@angular/common'; |
4 | 4 | import {BusyTrackerService} from './service/busy-tracker.service'; |
5 | 5 | import {BusyConfigHolderService} from './service/busy-config-holder.service'; |
6 | | -import { NgBusyDirective } from './ng-busy.directive'; |
7 | | -import { NgBusyComponent } from './component/ng-busy/ng-busy.component'; |
8 | | -import { NgBusyBackdropComponent } from './component/ng-busy-backdrop/ng-busy-backdrop.component'; |
| 6 | +import {NgBusyDirective} from './ng-busy.directive'; |
| 7 | +import {NgBusyComponent} from './component/ng-busy/ng-busy.component'; |
| 8 | +import {NgBusyBackdropComponent} from './component/ng-busy-backdrop/ng-busy-backdrop.component'; |
9 | 9 |
|
10 | 10 | @NgModule({ |
11 | | - imports: [CommonModule], |
12 | | - declarations: [DefaultBusyComponent, NgBusyDirective, NgBusyComponent, NgBusyBackdropComponent], |
13 | | - providers: [BusyConfigHolderService, BusyTrackerService], |
14 | | - exports: [NgBusyDirective], |
15 | | - entryComponents: [DefaultBusyComponent, NgBusyBackdropComponent, NgBusyComponent] |
| 11 | + imports: [CommonModule], |
| 12 | + declarations: [DefaultBusyComponent, NgBusyDirective, NgBusyComponent, NgBusyBackdropComponent], |
| 13 | + providers: [BusyConfigHolderService, BusyTrackerService], |
| 14 | + exports: [NgBusyDirective], |
| 15 | + entryComponents: [DefaultBusyComponent, NgBusyBackdropComponent, NgBusyComponent] |
16 | 16 | }) |
17 | 17 | export class NgBusyModule { |
18 | | - static forRoot(config: BusyConfig): ModuleWithProviders { |
19 | | - return { |
20 | | - ngModule: NgBusyModule, |
21 | | - providers: [ |
22 | | - {provide: BusyConfig, useValue: config} |
23 | | - ] |
24 | | - }; |
25 | | - } |
| 18 | + static forRoot(config: IBusyConfig): ModuleWithProviders { |
| 19 | + const conf = Object.assign(BUSY_CONFIG_DEFAULTS, config); |
| 20 | + return { |
| 21 | + ngModule: NgBusyModule, |
| 22 | + providers: [ |
| 23 | + {provide: BusyConfig, useValue: conf} |
| 24 | + ] |
| 25 | + }; |
| 26 | + } |
26 | 27 | } |
0 commit comments