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
  • 17,096
  • 9
  • 72
  • 137
  • 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
  • 17,096
  • 9
  • 72
  • 137
Aravind
  • 38,787
  • 15
  • 88
  • 108