rohit raut rohit raut - 2 months ago 16
AngularJS Question

How to get id from url in angularjs

I am having trouble to get Id from url as follows:

How can I get 42 from this url in angularjs? Is there any way in angularjs $location to fetch the same?.

var href = window.location.href;

$ = href.substr(href.lastIndexOf('/') + 1).replace('#', '');

if your url is:

Then you get output, 42