简体   繁体   中英

Angular2 router: how to navigate to certain path?

I have module that has its routing settings and contains some children modules. How can i navigate to certain routes from some children to parent or to other (sibling) modules?

As i see I could specify a name for the route:

{ path:'/About', name: 'About',   ... }

and then use it:

this.router.parent.navigate(['About']);

Since name is deprecated, do you know how can i reach the same with the latest version of Angular2 router?

simply use

this.router.navigate(['/XYZ', params_here]);

or if you want to redirect directly to path then you can also use this

this.router.navigateByUrl('/XYZ/ABC');

navigateByUrl accepts simply string

name has been deprecated in the angular2 beta i think, now the routing is working by matching name with the path name

for more info read out here

https://angular.io/docs/ts/latest/guide/router.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM