Skip to content

Commit 6a42e0d

Browse files
committed
feat(navigation): supportrelative URLs.
1 parent a8baf8a commit 6a42e0d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/pages/navigation/angular.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,24 @@ export class LoginComponent {
115115

116116
Both options provide the same navigation mechanism, just fitting different use cases.
117117

118-
> A note on navigation with relative URLs: Currently, to support multiple navigation stacks, relative URLs are something not supported
118+
And we also can use navigate relative URLs by `ActivatedRoute` and `relativeTo`.
119+
120+
```typescript
121+
import { Component } from '@angular/core';
122+
import { ActivatedRoute, Router } from '@angular/router';
123+
124+
@Component({
125+
...
126+
})
127+
export class LoginComponent {
128+
129+
constructor(private router: Router, private route: ActivatedRoute,){}
130+
131+
navigate(){
132+
this.router.navigate(['/detail'], { relativeTo: this.route })
133+
}
134+
}
135+
```
119136

120137
## Lazy loading routes
121138

0 commit comments

Comments
 (0)