From 5eda008019d40d7e867f300d5520fed9c72a838c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A6=8A=E5=8E=9F=E6=98=8C=E5=BD=A6?= Date: Thu, 4 Apr 2019 12:58:04 +0900 Subject: [PATCH] docs(navigation): support relative urls. --- src/pages/navigation/angular.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pages/navigation/angular.md b/src/pages/navigation/angular.md index 5c822256ef1..5837b78fc5e 100755 --- a/src/pages/navigation/angular.md +++ b/src/pages/navigation/angular.md @@ -115,7 +115,24 @@ export class LoginComponent { Both options provide the same navigation mechanism, just fitting different use cases. -> A note on navigation with relative URLs: Currently, to support multiple navigation stacks, relative URLs are something not supported +And we also can use navigate relative URLs by `ActivatedRoute` and `relativeTo`. + +```typescript +import { Component } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +@Component({ + ... +}) +export class LoginComponent { + + constructor(private router: Router, private route: ActivatedRoute,){} + + navigate(){ + this.router.navigate(['/detail'], { relativeTo: this.route }) + } +} +``` ## Lazy loading routes