Call local storage within platform ready

HI all, I can use local storage most of the situation. However, this time I need to use local storage within this.platform.ready().then().
I am getting the Typescript error, : Cannot read property ‘local’ of undefined.
I am wondering how to define local storage function within this.platform.ready().then()
Could anyone give a help?
Many thanks.


import {Storage, LocalStorage} from 'ionic-angular'; @Component({ templateUrl: 'build/app.html' }) class MyApp { public local: Storage; constructor(private platform:Platform){ this.initializeApp(); } initializeApp() { this.platform.ready().then(() => { savesth(); } function savesth(){ this.local.set('saveValue', 'test'); } } ionicBootstrap(MyApp);

The problem is that you never initialize your local variable.

I’d recommend checking out the local storage documentation:

I think a larger problem is execution context. I would recommend reading this about this.