I get acquainted with Angular2, Ionic2 and maybe I misunderstand something, but I was hoping for help.
I have a provider called "CurrentUser" to store and retrieve LocalStorage data.
getProfile(): any { this.local.get("user-profile").then((profile) => { var val = JSON.parse(profile); return val; }); }
this getProfile() function returns a promise
If I introduce this provider into the component. How will I wait for the promise to resolve before assigning data when calling this function from the component ?.
@Component({ templateUrl: 'build/pages/book_meeting/book_meeting.html' }) export class BookMeetingPage implements OnInit { constructor(public navCtrl: NavController, private _currentUser: CurrentUser) { } profile: IProfile; ngOnInit(): any { this.profile = this._currentUser.getProfile(); console.log(this.profile);
promise angular typescript ionic2
Arianule
source share