You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thx for your nice tutorials. I have a question about your commit 6cab53e.
I put my login() method in a separate injectable service which I call in my component. But my component don't reload after login when I use this.ngZone.run(() => self.loggedIn());
How can I achieve that the component and the ngOnInitwill be update/refresh after the login?
Here my service:
@Injectable()
export class AuthService {
constructor (private ngZone: NgZone) {
this.ngZone = ngZone;
}
lock = new Auth0Lock('EjqKkgN1EWF0ssIb281Z1jRab4UpLqWy', 'larz.eu.auth0.com');
login() {
var self = this;
this.lock.show((error: string, profile: Object, id_token: string) => {
if (error) {
console.log(error);
}
// We get a profile object for the user from Auth0
localStorage.setItem('profile', JSON.stringify(profile));
// We also get the user's JWT
localStorage.setItem('id_token', id_token);
this.ngZone.run(() => self.loggedIn());
});
}
The reason I do
this.ngZone.run(() => self.loggedIn());
is because my view is evaluating a method on the component called loggedIn() from a *ngIf. To do that from a service that you're not even binding to doesn't make sense.
Also it doesn't look like you have a method called loggedIn() in your service if you'd write your code in typescript it shouldn't compile.
Anyways this is not an issue related to this repo so I'm closing this ticket.
Hi Ajden,
thx for your nice tutorials. I have a question about your commit 6cab53e.
I put my
login()
method in a separate injectable service which I call in my component. But my component don't reload after login when I usethis.ngZone.run(() => self.loggedIn());
How can I achieve that the component and the
ngOnInit
will be update/refresh after the login?Here my service:
my component:
The text was updated successfully, but these errors were encountered: