How to prevent view redrawing when changing a route in AngularJS

I am creating a web application where users can view objects on a map, click a marker and go to a new view with information. From this point of view, they can penetrate deeper into more detailed information.

Sort of:

  • /map
  • / tree / {treeid}
  • / tree / {treeid} / Information / {informationid}

I know how to keep the actual state of a model when moving between routes / states. The problem is that I donโ€™t want to recount the entire map (using markers and everything) when I return to the browser history. In other words, I want to keep the / map state displayed as I move further.

This can be easily done using the search options instead of the routes on the map / map (i.e. / map? Treeid = 10) and disable reboot during the search and perform ng-hide = "treeid" on the map object and ng-show on the tree object -info.

My question is, is there a better, more suitable way in angular?

Thanks in advance.

+4
source share
3 answers

Turning to the โ€œrecalculate entire mapโ€ question, one way to solve this problem is to draw a Google map at the same level as yours ng-viewand move it from the view to hide it.

, , :
http://plnkr.co/edit/wsjYoG2uXxYxXTmWdFGh?p=preview

, , , , .

+2

. , . - :

angular.module('myApp').factory('GlobalService', [
    function() {
        var _this = this;
        _this._data = {
            user: window.user,
            authenticated: !! window.user
        };

        return _this._data;
    }
]); 


angular.module('myApp').controller('FooController',
    ['$scope', 'GlobalService',
    function ($scope, GlobalService) {
    $scope.global = GlobalService;
    $scope.global.bar = someData;
    ...
]);
0

: AngularJS . , / .

0

Source: https://habr.com/ru/post/1530179/


All Articles