I am trying to get query string values using angularjs.
my Url: http://localhost/example.php?sportsId=3
when I applied var goto = $locati
This is what I use. It's essentially the same as the accepted answer but returns all parameters as an object and handle decoding of url components.
function getUrlParameters() {
var pairs = window.location.search.substring(1).split(/[&?]/);
var res = {}, i, pair;
for (i = 0; i < pairs.length; i++) {
pair = pairs[i].split('=');
if (pair[1])
res[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
return res;
}