angular-router

Custom RouteReuseStrategy for Angular's child module

青春壹個敷衍的年華 提交于 2019-11-27 15:21:48
问题 I want to use this custom route reuse strategy for just one module: export class CustomRouteReuseStrategy extends RouteReuseStrategy { public shouldDetach(route: ActivatedRouteSnapshot): boolean { return false; } public store(route: ActivatedRouteSnapshot, detachedTree: DetachedRouteHandle): void {} public shouldAttach(route: ActivatedRouteSnapshot): boolean { return false; } public retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle { return null; } public shouldReuseRoute(future:

How do I navigate to a parent route from a child route?

别等时光非礼了梦想. 提交于 2019-11-27 11:01:10
My problem is quite classic. I have a private part of an application which is behind a login form . When the login is successful, it goes to a child route for the admin application. My problem is that I can't use the global navigation menu because the router tries to route in my AdminComponent instead of my AppCompoment . So my navigation is broken. Another problem is that if someone want to access the URL directly, I want to redirect to the parent "login" route. But I can't make it work. It seems to me like theses two issues are similar. Any idea how it can be done? Mark Rajcok Do you want a

How to use angular 6 Route Auth Guards for all routes Root and Child Routes?

萝らか妹 提交于 2019-11-27 10:03:14
问题 How to use angular 6 Route Auth Guards for all routes Root and Child Routes ? 回答1: 1) [ Create guard, the file name would be like auth.guard.ts ] ng generate guard auth import { Injectable } from '@angular/core'; import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { Observable } from 'rxjs/Observable'; import { AuthService } from './auth.service'; import {Router} from '@angular/router'; @Injectable() export class AuthGuard implements CanActivate

Best method to set different layout for different pages in angular 4

南笙酒味 提交于 2019-11-27 09:09:31
问题 I am new to angular 4. What I'm trying to achieve is to set different layout headers and footers for different pages in my app. I have three different cases: Login, register page (no header, no footer) routes: ['login','register'] Marketing site page (this is the root path and it has a header and footer, mostly these sections come before login) routes : ['','about','contact'] App logged in pages (I have a different header and footer in this section for all the app pages but this header and

Angular2 router appends component instead of replacing it

爱⌒轻易说出口 提交于 2019-11-26 22:43:22
问题 I have an Angular2 application with one router outlet that displays different components depending on which link is clicked in a side menu. The markup for the main component containing the <router-outlet> looks like this <div *ngIf="authenticated == false"> <app-login></app-login> </div> <div *ngIf="authenticated"> <div class="page home-page"> <header class="header"> <app-navbar></app-navbar> </header> <div class="page-content d-flex align-items-stretch"> <div class="sidebar-container"> <app

How do I navigate to a parent route from a child route?

拈花ヽ惹草 提交于 2019-11-26 12:03:09
问题 My problem is quite classic. I have a private part of an application which is behind a login form . When the login is successful, it goes to a child route for the admin application. My problem is that I can\'t use the global navigation menu because the router tries to route in my AdminComponent instead of my AppCompoment . So my navigation is broken. Another problem is that if someone want to access the URL directly, I want to redirect to the parent \"login\" route. But I can\'t make it work.