AME
AME

Reputation: 2302

change url and reload after $location.search()

Sounds simple but I'm kinda stuck here.

$scope.triggerFetch = function() {
       $location.search("zipcode", 344343); // this just replaces it but I need a reload as well
       // now do the GET request
}

I use angular just for the UI interactions, the rendering and the heavy lifting does the backend framework.

I can replace the url but I need a function for the reload, I don't want to use $location.path(), there must be something more elegant.

Upvotes: 1

Views: 1727

Answers (1)

major-mann
major-mann

Reputation: 2652

(From the comments)

You can either add ngRoute as a dependency which will cause a reload when the search parameters are changed.

Option 2 is to do something like the following:

$scope.$watchCollection($location.search(), function () {
    $window.location.reload();
})

Upvotes: 1

Related Questions