I'm new to angular 2 actually im facing issue when i am refresh its redirect to login page but actually i wants redirected to dashboard
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
// get observable
const observable = this.store.select(isAuthenticated);
// redirect to sign in page if user is not authenticated
observable.subscribe(authenticated => {
if (!authenticated) {
this.router.navigate(['/login']);
}
});
return observable;
}
routing module:
const routes: Routes = [
{
canActivate: [AuthGuard],
path: "dashboard",
loadChildren: "./dashboard/dashboard.module#DashboardModule"
},
{
path: "",
pathMatch: "full",
redirectTo: "dashboard"
}
];