How to use the relativeTo parameter jump of Router.navigate in javascript and Angular
Editor to share with you how to use the relativeTo parameter jump of Router.navigate in javascript and Angular. I hope you will get something after reading this article. Let's discuss it together.
When using this.router.navigate (['.. /'], {relativeTo:this.route}) for route redirection, V1Component and V2Component cannot return to the previous page by means of'.. /','.. /.. /', but V3Component can. Why?
Relativeto file directory
Clipboard.png
Relativeto routing
Constroutes:Routes= [
{path:'',redirectTo:'page',pathMatch:'full'}
{
Path:'page'
Children: [
{path:'',component:PageComponent}
{
Path:'v1'
Children: [
{path:'',component:V1Component}
{
Path:'v2'
Children: [
{path:'',component:V2Component}
{path:'v3',component:V3Component}
]
}
]
}
]
}
]
V1
I'm v1.
Enter v2
Enter v3
Back to page
GoV2 () {
This.router.navigate (['v2'], {relativeTo:this.route})
}
GoV3 () {
This.router.navigate (['v2amp v3'], {relativeTo:this.route})
}
BackPage () {
This.router.navigate (['.. /'], {relativeTo:this.route}); / / No response
}
After reading this article, I believe you have a certain understanding of "how to use the relativeTo parameter jump of Router.navigate in javascript and Angular". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!