|
1 | 1 | import { ModuleWithProviders, NgModule } from '@angular/core'; |
2 | 2 | import { FastSvgComponent } from './fast-svg.component'; |
3 | | -import { SvgRegistry } from './svg-registry.service'; |
4 | | -import { CommonModule } from '@angular/common'; |
5 | 3 | import { FastSvgProviderOptions } from './provider-config.interface'; |
6 | | -import { SvgLoadStrategyImpl } from './token/svg-load.strategy'; |
7 | | -import { SvgLoadStrategy } from './token/svg-load.strategy.model'; |
8 | | -import { SvgOptionsToken } from './token/svg-options.token'; |
9 | | -import { SvgOptions } from './token/svg-options.model'; |
| 4 | +import { provideFastSVG } from './fast-svg.provider'; |
10 | 5 |
|
11 | 6 | @NgModule({ |
12 | | - imports: [CommonModule], |
13 | | - declarations: [FastSvgComponent], |
| 7 | + imports: [FastSvgComponent], |
14 | 8 | exports: [FastSvgComponent], |
15 | 9 | }) |
16 | 10 | export class FastSvgModule { |
17 | 11 | static forRoot( |
18 | | - providers: FastSvgProviderOptions |
| 12 | + options: FastSvgProviderOptions |
19 | 13 | ): ModuleWithProviders<FastSvgModule> { |
20 | | - const svgOptions: SvgOptions = { |
21 | | - url: providers.url, |
22 | | - }; |
23 | | - providers?.suspenseSvgString && |
24 | | - (svgOptions.suspenseSvgString = providers.suspenseSvgString); |
25 | | - providers?.defaultSize && (svgOptions.defaultSize = providers.defaultSize); |
26 | | - |
27 | 14 | return { |
28 | 15 | ngModule: FastSvgModule, |
29 | | - providers: [ |
30 | | - { |
31 | | - provide: SvgLoadStrategy, |
32 | | - useClass: providers.svgLoadStrategy || SvgLoadStrategyImpl, |
33 | | - }, |
34 | | - { |
35 | | - provide: SvgOptionsToken, |
36 | | - useValue: svgOptions, |
37 | | - }, |
38 | | - SvgRegistry, |
39 | | - ], |
| 16 | + providers: [provideFastSVG(options)], |
40 | 17 | }; |
41 | 18 | } |
42 | 19 |
|
|
0 commit comments