0

consider my url is like

#/desktop/admin/reconciliationconfig/nav/ledger/GMO-DDA-21819971/detail,

My question is how can I get all segments of the route in angular?

My expected result is

['desktop','admin','reconciliationconfig','nav','ledger','GMO-DDA-21819971','detail']

Note GMO-DDA-21819971 is a route param and will be changed dynamically

Reza
  • 18,865
  • 13
  • 88
  • 163
  • Use any method mentioned in [this post](https://stackoverflow.com/questions/34597835/how-to-get-current-route) to get the URL and then parse it into an array based off the forward slash? – Narm Jun 05 '19 at 16:41

1 Answers1

1

After getting the url from the router object, you can simply use the split function in the string

this.router.url.split('/');
Reza
  • 18,865
  • 13
  • 88
  • 163
Aravind
  • 40,391
  • 16
  • 91
  • 110