LocalStorage Error


#1

I am trying to use locale storage service as descried here. http://ionicframework.com/docs/v2/api/platform/storage/LocalStorage/

But i am getting this run-time exception

1     067673   group    EXCEPTION: Error during instantiation of MyApp!.
2     067673   error    EXCEPTION: Error during instantiation of MyApp!.
3     067673   error    ORIGINAL EXCEPTION: TypeError: Illegal constructor
4     067674   error    ORIGINAL STACKTRACE:
5     067674   error    TypeError: Illegal constructor
    at TypeError (native)
    at new MyApp (http://localhost:8101/build/js/app.bundle.js:3198:23)
    at http://localhost:8101/build/js/app.bundle.js:8088:52
    at Injector._instantiate (http://localhost:8101/build/js/app.bundle.js:6646:28)
    at Injector._instantiateProvider (http://localhost:8101/build/js/app.bundle.js:6600:26)
    at Injector._new (http://localhost:8101/build/js/app.bundle.js:6589:22)
    at InjectorInlineStrategy.instantiateProvider (http://localhost:8101/build/js/app.bundle.js:6089:31)
    at ElementDirectiveInlineStrategy.init (http://localhost:8101/build/js/app.bundle.js:18975:25)
    at new AppElement (http://localhost:8101/build/js/app.bundle.js:18652:29)
    at HostViewFactory.viewFactory_HostMyApp0 [as viewFactory] (viewFactory_HostMyApp:73:24)
6     067674   error    ERROR CONTEXT:

Here is my implementation

import {App, IonicApp, Platform,LocalStorage} from 'ionic-angular';

 @App({
    template: '<ion-nav [root]="rootPage"></ion-nav>',
   )


export class MyApp {
 
     local;

    constructor(platform: Platform) {
        this.local = new Storage(LocalStorage);
        this.local.set('didTutorial', true);
    }
 }

#2

What about using the window.localStorage?


#3

I know that this will work, but i need to know what is wrong with LocalStorage service, If it is broken or what


#4

if YOU need know it, then YOU must do debugging.
if you want open issue, then you’re wrong place :slight_smile:


#5

Is missing import the Storage. Do this:
import {App, IonicApp, Platform,LocalStorage,Storage} from ‘ionic-angular’;