ionic2 - why does ionic storage does not work outside a function -
i using ionic 2 storage. if keep storage code outside of function not work. kindly let me know.
constructor(public navctrl: navcontroller, public settings: settings, public formbuilder: formbuilder, public navparams: navparams, public translate: translateservice, private storage : storage) { } this.settings.load().then(() => { this.settingsready = true; this.options = this.settings.allsettings; this._buildform(); }); this.storage.set('nam','par'); }
the constructor special function of class responsible initializing variables of class. typescript
defines constructor using constructor
keyword. constructor function , hence can parameterized. until variable get's initialized remains undefined. so, can't in way , make no sense, constructor initialized before either can same operation within constructor or use life cycle event in ionic so.
Comments
Post a Comment