Hi I am developing an ionic-angular pwa and recently I decided to use local storage to store authentication info. I followed the steps according to Ionic Storage
But in the end I get the following error:
AppComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: Cannot read property 'platformId' of undefined
at provideStorage (ionic-storage-angular.js:49)
at _callFactory (core.js:23707)
at _createProviderInstance (core.js:23663)
The only way I could solve the error is to add Storage to the Providers list in app.module.ts; But according to recent release I should not. I would be thankful if you can tell my what is wrong.
My packages versions are:
"@ionic/angular": "^5.5.2",
"@ionic/storage": "^2.3.1",
"@ionic/storage-angular": "^3.0.6",
Yes I was able to solve this error by adding Storage to the Providers list in app.module.ts. However you need to import the Storage package from @ionic/storage-angular rather than @ionic/storage
Try this in your app.module.ts
import { IonicStorageModule,Storage } from '@ionic/storage-angular'; @NgModule({ imports: [ IonicStorageModule.forRoot() ], providers: [ Storage ] }) export class AppModule { }
And this is the only way it worked for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.