For versions >= 8, you should install this library with this command:
ng add @ngx-pwa/local-storage
If it causes an error, please file an issue.
In the meantime, you can proceed to a manual installation, but be sure to follow all the steps below.
Install the right version according to your Angular one via npm
:
# For Angular 9:
npm install @ngx-pwa/local-storage@9
# For Angular 8:
npm install @ngx-pwa/local-storage@8
# For Angular 6 & 7:
npm install @ngx-pwa/local-storage@6
# For Angular 5:
npm install @ngx-pwa/local-storage@5
# For Angular 4:
npm install @ngx-pwa/local-storage@5
You're done, nothing else to do.
An additional setup step is required for version 8 only and only for new applications:
import { StorageModule } from '@ngx-pwa/local-storage';
@NgModule({
imports: [
StorageModule.forRoot({
IDBNoWrap: true,
})
]
})
export class AppModule {}
Note:
- must be done at initialization, ie. in
AppModule
, and must not be loaded again in another module, - never change these options in an app already deployed in production, as all previously stored data would be lost. If you are already using the lib, you should use the migrations guides.
You're done, nothing else to do.
A different additional setup step is required for versions 4 & 5 only:
include the LocalStorageModule
in your app root module (just once, do not re-import it in your submodules).
import { LocalStorageModule } from '@ngx-pwa/local-storage';
@NgModule({
imports: [
BrowserModule,
LocalStorageModule,
...
]
...
})
export class AppModule {}