Reputation: 388
How can I get URI components in AngularJS? For example I have http://domain.com/photo/1
So how can I get that second segment (=1) to a variable in angular? Thank you.
Upvotes: 1
Views: 1225
Reputation: 2119
You don't need Angular for that, you can simply do:
var url = document.URL.split('/'); // Get the current full url, eg: http://domain.com/photo/1 splitted by slashes
var lastArg = url[url.length]; // Get the last string after the last slash
Upvotes: 1