How to cache compiled templates in AngularJS ?

32 views
Skip to first unread message

Andrey Jakovenko

unread,
Jan 1, 2017, 3:01:28 PM1/1/17
to Angular
Initially corner caches only the templates that would ship them back to the server, without compiling with $cacheFactory.
In the project I have a few places where it is used the same directive. I do not mean that the directive would be compiled again during the transition to another page, and was taken from the cache (ie, template) and is simply inserted into the template.
Is it possible to somehow do it to templates for ngRoute directive? Type have to create guide

Sander Elias

unread,
Jan 4, 2017, 3:35:19 AM1/4/17
to Angular
Hi Andrey,

Templates are cached by default in angular 1.x You can't simply cache compiled templates. There are technical reasons for this. To put this overly simple, once compiled the templates are tightly coupled to a piece of DOM, and to their place in the $scope hierarchy. It's very difficult to keep everything in place once you take it out and insert it at another place.

Regards
Sander

Reply all
Reply to author
Forward
0 new messages