I'm trying to get a parameter from the URL without having a router in the specific page. I've read that you can use $location.search().clearCart and that'll give the value of clearCart . I get undefined. Is there a way of getting this without using a router?
The url is: http://ec2-50-17-53-129.compute-1.amazonaws.com/home?clearCart=true
this is my controller:
app.controller('cartCtrl', function ($scope, $rootScope, $http, $location, dialogs, ngCart) {
if(($location.search()).clearCart != 'undefined' && ($location.search()).clearCart == 'true'){
for(var i = 0; i < ngCart.getTotalItems(); i++){
ngCart.removeItem(i);
}
}
}
$location.search()returns an object which is a series of key:value pairs. Have you tried logging$location.search()to the console to see if your key is in the object?