[英]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: 如我所见,我可以为路线指定一个name
:
{ 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? 由于不建议使用name
,您是否知道如何使用最新版本的Angular2路由器达到相同的名称?
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 navigateByUrl
接受简单的字符串
name has been deprecated in the angular2 beta i think, now the routing is working by matching name with the path name 我认为在angular2 beta中已不推荐使用名称,现在路由通过将名称与路径名称匹配来工作
for more info read out here 欲了解更多信息,请点击这里
https://angular.io/docs/ts/latest/guide/router.html https://angular.io/docs/ts/latest/guide/router.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.