Closed toni-moreno closed 7 years ago
I've changed my routes to
export const routes: Routes = [
{ path: '', component: Login },
{ path: './login', component: Login },
{ path: './home', component: Home, canActivate: [AuthGuard] },
];
First Path '' linked to Login and removed last, and now routing is crashing
When debugging inside the login.ts login method we are doing a call to this.router.navigate() but this.router == undefined as you can see in the following screenshot.
Can anybody tell me whats the matter?
I've finally fix with
import { Routes } from '@angular/router';
import { Home } from '../home/home';
import { Login } from '../login/login';
import { AuthGuard } from '../common/auth.guard';
export const routes: Routes = [
{ path: '', component: Login },
{ path: 'login', component: Login },
{ path: 'home', component: Home, canActivate: [AuthGuard] },
];
Thank you !!
I've completely copied your schema to my project in order to provide authentication capabilities.
https://github.com/toni-moreno/snmpcollector/blob/angular2_final_migration/public/app/app.routes.ts
I'have default path to load login form
It loads ok , and do session creation request .
stores token in LocalStorage and do this.router.navigate(['/home']);
now browser url change but nothing more happens
If I change config to first load home
it reloads ok the home page it seems like the real reload is not done. No errors in the browser console.
NOTE: I'm migrating now from angular2.0.0.-betaXXX to final release and I've updated also your authentication sample, the old version was working ok