Explain $templateCache in AngularJs ?

devquora
devquora

Posted On: Feb 22, 2018

 

    2 Answers Written

  •  devquora
    Answered by Deshai

    $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', ...);
    }]);
    
  •  devquora
    Answered by Priyag Chaudhary

    Templatecache in Angularjs

    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.

Related Questions

Please Login or Register to leave a response.

Related Questions