Answer the question
In order to leave comments, you need to log in
AngularJS: how to cache rendered views?
How to change the behavior of AngularJS, so that when switching between different views, they are not redrawn each time?
Answer the question
In order to leave comments, you need to log in
my request: https://github.com/angular/angular.js/issues/3825
experience: use ng-include
What does "not redrawn" mean? If you just don't want to load the data from the server when the page opens, then just store the data in a service instead of loading it every time you build the controller.
You have to write your own ng-view directive to create such functionality.
The basic idea behind this is this:
Before changing routes, instead of destroying the current view, just store it in an invisible DIV cache, and unregister the scope listeners. Give the div element a data attribute with $$route.templateUrl
to be able to get it back. Then load a new page and reload listeners.
Before changing the route, check the cache, and if your DIV page has a cache, get the element from the cache, re-register the scope and insert it into the current View cache.
Try this directive https://github.com/rotorgames/angular-rg-cache-view
It doesn't delete dom but caches it keeping scope and all events.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question