Skip to content

Commit 2a5489b

Browse files
committed
docs: standalone
1 parent 45e3c3c commit 2a5489b

File tree

1 file changed

+20
-40
lines changed

1 file changed

+20
-40
lines changed

README.md

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,61 +25,41 @@ See the [stackblitz demo](https://stackblitz.com/edit/demo-ng-http-caching?file=
2525
npm i ng-http-caching
2626
```
2727

28-
*Step 2*: Import `NgHttpCachingModule` into your app module, eg.:
28+
*Step 2*: Provide `NgHttpCaching` into your `bootstrapApplication`, eg.:
2929

3030
```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';
3533
import { AppComponent } from './app.component';
34+
import { provideNgHttpCaching } from 'ng-http-caching';
3635

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+
});
5242
```
5343

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.:
5545

5646
```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';
6149
import { AppComponent } from './app.component';
62-
63-
import { NgHttpCachingModule, NgHttpCachingConfig } from 'ng-http-caching';
50+
import { provideNgHttpCaching, NgHttpCachingConfig } from 'ng-http-caching';
6451

6552
// your config...
6653
const ngHttpCachingConfig: NgHttpCachingConfig = {
6754
lifetime: 1000 * 10 // cache expire after 10 seconds
6855
};
6956

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+
});
8363
```
8464

8565
## Config

0 commit comments

Comments
 (0)