@@ -26,8 +26,45 @@ yarn add @push-based/ngx-fast-svg
26
26
27
27
### Setup
28
28
29
+ #### Setup the library in your standalone application:
30
+
31
+ ** main.ts**
32
+
33
+ ``` typescript
34
+ import { provideFastSVG } from ' @push-based/ngx-fast-svg' ;
35
+
36
+ bootstrapApplication (AppComponent , {
37
+ providers: [
38
+ // ... other providers
39
+ provideFastSVG ({
40
+ url : (name : string ) => ` path/to/svg-assets/${name }.svg ` ,
41
+ })
42
+ ]
43
+ });
44
+ ```
45
+
46
+ #### Setup the library in your Angular application using NgModules:
47
+
29
48
** app.module.ts**
30
49
50
+ ``` typescript
51
+ // ...
52
+ import { provideFastSVG } from ' @push-based/ngx-fast-svg' ;
53
+
54
+ @NgModule ({
55
+ declarations: [AppComponent ],
56
+ providers: [
57
+ provideFastSVG ({
58
+ url : (name : string ) => ` path/to/svg-assets/${name }.svg ` ,
59
+ })
60
+ ],
61
+ bootstrap: [AppComponent ]
62
+ })
63
+ export class AppModule {}
64
+ ```
65
+
66
+ or if you're using an older version of the library, you can still do:
67
+
31
68
``` typescript
32
69
// ...
33
70
import { FastSvgModule } from ' @push-based/ngx-fast-svg' ;
@@ -38,7 +75,7 @@ import { FastSvgModule } from '@push-based/ngx-fast-svg';
38
75
FastSvgModule .forRoot ({
39
76
url : (name : string ) => ` path/to/svg-assets/${name }.svg ` ,
40
77
})
41
- ]
78
+ ],
42
79
providers: [],
43
80
bootstrap: [AppComponent ]
44
81
})
@@ -98,6 +135,28 @@ import { HttpClientFetchStrategy } from './fetch-strategy';
98
135
export class AppModule {}
99
136
```
100
137
138
+ or in a standalone application:
139
+
140
+ ** main.ts**
141
+
142
+ ``` typescript
143
+ import { provideFastSVG } from ' @push-based/ngx-fast-svg' ;
144
+ import { loaderSvg } from ' ./assets' ;
145
+ import { HttpClientFetchStrategy } from ' ./fetch-strategy' ;
146
+
147
+ bootstrapApplication (AppComponent , {
148
+ providers: [
149
+ // ... other providers
150
+ provideFastSVG ({
151
+ url : (name : string ) => ` path/to/svg-assets/${name }.svg ` ,
152
+ defaultSize: ' 32' ,
153
+ suspenseSvgString: loaderSvg ,
154
+ svgLoadStrategy: HttpClientFetchStrategy
155
+ })
156
+ ]
157
+ });
158
+ ```
159
+
101
160
#### SSR Usage
102
161
103
162
You can provide your own SSR loading strategy that can look like this:
@@ -124,12 +183,13 @@ And then just provide it in you server module.
124
183
AppModule ,
125
184
ServerModule ,
126
185
ServerTransferStateModule ,
127
- FastSvgModule .forRoot ({
186
+ ],
187
+ providers: [
188
+ provideFastSVG ({
128
189
svgLoadStrategy: SvgLoadStrategySsr ,
129
190
url : (name : string ) => ` assets/svg-icons/${name }.svg ` ,
130
191
}),
131
192
],
132
- providers: [],
133
193
bootstrap: [AppComponent ],
134
194
})
135
195
export class AppServerModule {}
0 commit comments