I am building web app which has login and dashboard and simple routing;
I have two login options and routes:
Login options:
With email:
login(u) { this._loginService.login(u) .subscribe(data => { console.log('Email login successful!'); this._router.navigate(['/dashboard']); });With google:
googleLogin() { gapi.auth2.authorize({ client_id: * scope: 'email', response_type: 'code', prompt: 'select_account' }, (response) => { if (response.error) { return; } this._loginService.loginWithGoogle(response) .subscribe(response1 => { console.log('Google login successful!'); console.log(response); this._router.navigate(['/dashboard']); }); });Router options:
const appRoutes: Routes = [ { path: 'dashboard', component: MainComponent}, { path: 'login', component: LoginComponent }
When login with email succeeds, router navigates and no problem occures.
The problem is that when google logs in with google sign in and router navigates to /dashboard, app crashes in that ways:
- if i press button to change route, it just displays it view and does not remove my dashboard from dom.
- sometimes login page is not removed from dom
- other functions does not work in my code.
- NO ERRORS IN CONSOLE
when I reload the page, everything works just fine.