javascript - AngularJS: what is $templateCache? -


while profiling large angularjs app, started tracking $templatecache.

https://docs.angularjs.org/api/ng/service/$templatecache

what object? store partials stored on disk or final rendered html route?

i've added code controller make sure it's not persisting anything:

$scope.$on('$destroy', function cleanup() { $templatecache.removeall(); });

edit: reason looking single (not every) controller loading large partial several loops inside of it, depending on user input 100 input fields large <select> statements , many custom directives. client requesting way , want make sure of getting disposed during routing.

to clarify question: $templatecache storing partials appear on disk, no routing or rendering information being stored?

by default, while loading templates, angular looks inside $templatecache , fetches templates on xhr when cannot find them locally in $templatecache. when xhr request slow or our template large enough, can negatively impact end users’ experience . instead of fetching templates xhr, can fake template cache loading wrapping javascript file , shipp javascript file along rest of application.

sample :

angular.module('myapp') .run(['$templatecache', function($templatecache) { $templatecache.put('xyz.html', ...); }]); 

so, unless sure remove cached templates form $templatecache, don't that.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -