Posted On: Feb 22, 2018
$templateCache is an object in Angular where templates or HTML partials are stored locally. It helps angular applications to load faster. Whenever a request is made for any HTML file through routing, directive, or include angular first looks into $templateCache, if the requested file is not available in cache then it makes an HTTP request and puts the output in $templateCache for later uses. You can configure $templateCache by adding the following line of code in your angular Module.
angular.module('myApp') .run(['$templateCache', function($templateCache) { $templateCache.put('abc.html', ...); }]);
Templatecache in Angularjs is Cache object that is created by $cacheFactory.It is used for quick retrieval of data. Before loading templates Angular looks particular template is available inside $templateCache or not. If it is not present in Templatecache then fetches templates over XHR otherwise return the cached data.
Never Miss an Articles from us.
Explain the architecture of AngularJS?..
What is the Template in AngularJS?..