exiadbq exiadbq - 1 year ago 116
AngularJS Question

$TemplateCache or TemplateUrl for directive

I have $http.get all the html templates into the $TemplateCache, my question is for my directives is it more efficient to use

TemplateUrl : abc.html


Template : $TemplateCache.get('abc.html')?

Answer Source

templateUrl will request the html for the first time and will put it in templateCache, so only the first time you will have the hit to the server and NOT for each time.

templateCache would avoid that hit even for the first time.

you can use this grunt to put all your templates at once in the template cache, to avoid hitting server for each template. This would make it much more efficient.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download