I have a component with ngOnInit()
and a login()
method.
How can I update the component and execute my ngOnInit methods again after the login is done?
ngOnInit() {
this.loading = true;
this._guestService.getAllGuests()
.subscribe(
guests => this.guests = guests,
err => console.log(err),
() => console.log('Request Complete')
)
}
login() {
this.auth.login();
}
logout() {
this.auth.logout();
}
auth.login
service:
login() {
this.lock.show((error: string, profile: Object, id_token: string) => {
if (error) {
console.log(error);
}
localStorage.setItem('profile', JSON.stringify(profile));
localStorage.setItem('id_token', id_token);
});
}