Maniek Stasz Maniek Stasz - 1 year ago 234
AngularJS Question

Back button when reloadOnSearch:false

I've got

with three
views: search filters, products, pagination. I want to:

  1. filter products without reloading whole page just products view

  2. add filters to the url eg.

  3. be able to use back and next buttons

I set
reloadOnSearch: false
. Now when I invoke
function url changes, but the page is not reloaded. That's what I wanted to achieve, but when I click back button the products does not reload to its previous state. The only thing which happens is a change of url. The question is how can I handle back and next button events in this situation?

Answer Source

If you do reloadOnSearch:false, the same instance of the controller is used and any back forward does not reload any controller or related view. You need to respond to $routeUpdate event that gets raised in such scenarios. See $route documentation regarding this.

$scope.$on('$routeUpdate',function(e) {
   // Code to handle the route change.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download