如何获取 angular 中的所有路线段
How to get all segments of route in angular
考虑一下我的 url 就像
#/desktop/admin/reconciliationconfig/nav/ledger/GMO-DDA-21819971/detail
、
我的问题是如何获取 angular 中的所有路线段?
我的预期结果是
['desktop','admin','reconciliationconfig','nav','ledger','GMO-DDA-21819971','detail']
注意GMO-DDA-21819971
是路由参数,会动态改变
从router
对象中得到url后,可以简单的在string
中使用split
函数
this.router.url.split('/');
考虑一下我的 url 就像
#/desktop/admin/reconciliationconfig/nav/ledger/GMO-DDA-21819971/detail
、
我的问题是如何获取 angular 中的所有路线段?
我的预期结果是
['desktop','admin','reconciliationconfig','nav','ledger','GMO-DDA-21819971','detail']
注意GMO-DDA-21819971
是路由参数,会动态改变
从router
对象中得到url后,可以简单的在string
split
函数
this.router.url.split('/');