@@ -25,61 +25,41 @@ See the [stackblitz demo](https://stackblitz.com/edit/demo-ng-http-caching?file=
25
25
npm i ng-http-caching
26
26
```
27
27
28
- * Step 2* : Import ` NgHttpCachingModule ` into your app module , eg.:
28
+ * Step 2* : Provide ` NgHttpCaching ` into your ` bootstrapApplication ` , eg.:
29
29
30
30
``` ts
31
- import { BrowserModule } from ' @angular/platform-browser' ;
32
- import { NgModule } from ' @angular/core' ;
33
- import { HttpClientModule } from ' @angular/common/http' ;
34
- import { AppRoutingModule } from ' ./app-routing.module' ;
31
+ import { bootstrapApplication } from ' @angular/platform-browser' ;
32
+ import { provideHttpClient , withInterceptorsFromDi } from ' @angular/common/http' ;
35
33
import { AppComponent } from ' ./app.component' ;
34
+ import { provideNgHttpCaching } from ' ng-http-caching' ;
36
35
37
- import { NgHttpCachingModule } from ' ng-http-caching' ;
38
-
39
- @NgModule ({
40
- declarations: [AppComponent ],
41
- imports: [
42
- BrowserModule ,
43
- AppRoutingModule ,
44
- HttpClientModule ,
45
- NgHttpCachingModule ,
46
- ],
47
- providers: [],
48
- bootstrap: [AppComponent ],
49
- ],
50
- })
51
- export class AppModule { }
36
+ bootstrapApplication (AppComponent , {
37
+ providers: [
38
+ provideNgHttpCaching (),
39
+ provideHttpClient (withInterceptorsFromDi ())
40
+ ]
41
+ });
52
42
```
53
43
54
- if you want configure ` NgHttpCachingModule ` , you can pass a configuration to the module , eg.:
44
+ if you want configure ` ng-http-caching ` , you can pass a configuration, eg.:
55
45
56
46
``` ts
57
- import { BrowserModule } from ' @angular/platform-browser' ;
58
- import { NgModule } from ' @angular/core' ;
59
- import { HttpClientModule } from ' @angular/common/http' ;
60
- import { AppRoutingModule } from ' ./app-routing.module' ;
47
+ import { bootstrapApplication } from ' @angular/platform-browser' ;
48
+ import { provideHttpClient , withInterceptorsFromDi } from ' @angular/common/http' ;
61
49
import { AppComponent } from ' ./app.component' ;
62
-
63
- import { NgHttpCachingModule , NgHttpCachingConfig } from ' ng-http-caching' ;
50
+ import { provideNgHttpCaching , NgHttpCachingConfig } from ' ng-http-caching' ;
64
51
65
52
// your config...
66
53
const ngHttpCachingConfig: NgHttpCachingConfig = {
67
54
lifetime: 1000 * 10 // cache expire after 10 seconds
68
55
};
69
56
70
- @NgModule ({
71
- declarations: [AppComponent ],
72
- imports: [
73
- BrowserModule ,
74
- AppRoutingModule ,
75
- HttpClientModule ,
76
- NgHttpCachingModule .forRoot (ngHttpCachingConfig )
77
- ],
78
- providers: [],
79
- bootstrap: [AppComponent ]
80
- ],
81
- })
82
- export class AppModule { }
57
+ bootstrapApplication (AppComponent , {
58
+ providers: [
59
+ provideNgHttpCaching (ngHttpCachingConfig ),
60
+ provideHttpClient (withInterceptorsFromDi ())
61
+ ]
62
+ });
83
63
```
84
64
85
65
## Config
0 commit comments