如何获取 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('/');