Skip to content

Instantly share code, notes, and snippets.

@renesansz
Created November 2, 2015 18:49
Show Gist options
  • Select an option

  • Save renesansz/40ac3cbbe7365e6b89e3 to your computer and use it in GitHub Desktop.

Select an option

Save renesansz/40ac3cbbe7365e6b89e3 to your computer and use it in GitHub Desktop.
Template Cache service
(function () {
'use strict';
angular.module('app.factories').factory('TemplateCache', TemplateCache);
function TemplateCache($http, $templateCache) {
return {
Register: _Register
};
/////////////////////
// Factory Methods //
/////////////////////
/**
* Cache template views
*
* @param {String/Array} templateSrc - View template paths.
*/
function _Register(templateSrc) {
if (Array.isArray(templateSrc))
for (var i = 0, limit = templateSrc.length; i < limit; ++i)
_Register(templateSrc[i]);
else
$http.get(templateSrc, { cache: $templateCache });
}
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment