Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Using this.storage.get in the constructor

$
0
0

@miropolis wrote:

Hello,
right now I am trying to use a variable I am getting from my storage in the constructor of one of my pages. When I try to acces this variable in the constructor ( as in console.log("Number: ", number); ) it returns null.
What am I doing wrong?
This is my constructor:

constructor(public navCtrl: NavController, private storage: Storage, public navParams: NavParams) {
    let number;
    this.storage.get('group').then((val) => {
      number = val;
    });
    storage.ready().then(() => {
      console.log("Number: ", number);
    });
  }

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles