9

I've got ngView with three ngIncluded 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. ?category=shoes
  3. be able to use back and next buttons

I set reloadOnSearch: false in $routeProvier.when. Now when I invoke $location.search() 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?

4

2 回答 2

12

如果您执行 reloadOnSearch:false,则使用相同的控制器实例,并且任何后退都不会重新加载任何控制器或相关视图。您需要响应$routeUpdate在这种情况下引发的事件。请参阅有关此的 $route文档

$scope.$on('$routeUpdate',function(e) {
   // Code to handle the route change.
});
于 2013-09-24T04:05:22.790 回答
0

您必须手动处理所有事情。这意味着当您按下返回或下一步按钮时,您必须回到使用 $location 的状态。

于 2013-09-24T03:22:24.677 回答