we know this last post,
this.router.navigate(['/servers']);
this is absolute path. but funny thing is this code.
this.router.navigate(['servers']);
this looks like relative path. but it is not,
routerLink in html acts relatively with ['servers'] but navigate is not.
(do not wonder why. just it works like that.)
if you want to navigate relatively use this.
this.router.navigate(['servers'], {relativeTo: this.route});
route can be declared by this.
constructor(private serversService: ServersService,
private router:Router,
private route:ActivatedRoute) { }
'IT' 카테고리의 다른 글
[angular] QueryParameters and Fragments (0) | 2018.03.21 |
---|---|
[angular] route and parameter (0) | 2018.03.19 |
[angular] Router Navigation programmatically (0) | 2018.03.19 |
[angular] routerLinkActive and routerLinkOptions (0) | 2018.03.19 |
[angluar] routerLink with path (0) | 2018.03.19 |