如何获取当前路线 [英] How to get current route

查看:30
本文介绍了如何获取当前路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前的文档只讨论获取路由参数,而不是实际的路由段.

The current docs only talk about getting route params, not the actual route segments.

例如,如果我想找到当前路由的父级,那怎么可能?

For example, if i want to find the parent of current route, how is that possible?

推荐答案

Angular RC4:

Angular RC4:

你可以从@angular/router

然后注入它:

constructor(private router: Router ) {

}

然后调用它的 URL 参数:

Then call it's URL parameter:

console.log(this.router.url); //  /routename

这篇关于如何获取当前路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆