Reputation: 345
For instance if this Route is activated:
localhost/abc/xyz/:id/main
I want to know what is in place of main. Available options are 'main', 'feed', 'operations', 'associated', 'setting'.
it can be:
localhost/abc/xyz/:id/main
localhost/abc/xyz/:id/feed
localhost/abc/xyz/:id/operations
localhost/abc/xyz/:id/associated
localhost/abc/xyz/:id/setting
so whatever is written in the url at the last entry i want to capture that and use it in something.
Please mention the code to achieve this.
Thank you in Advance
Upvotes: 2
Views: 35
Reputation: 5241
You can get the path parts with something like this:
var segments = window.location.pathname.split('/');
And then you are looking for the last one in the list: segments[segments.length - 1]
Upvotes: 1