Persisting query string with AngularJS routing

前端 未结 6 2180
盖世英雄少女心
盖世英雄少女心 2021-01-05 18:11

I\'ve been working on a large Angular app for almost a year now and I\'m stuck trying to do what I expected to be trivial.

Here are two routes I have with params (sh

6条回答
  •  梦毁少年i
    2021-01-05 18:30

    Another solution I've found so far is to trace all $location.search() changes and store $window.location.search in a scope variable after each search change.

    Then just add this scope variable to all anchors in a template:

    
        Title
    
    

    In this case both routes reads scope variables from routeParams query string and uses $scope.$watch on those variables to reflect changes in $location.search and thus in anchors href attributes accordingly.

提交回复
热议问题