Created
November 2, 2015 18:49
-
-
Save renesansz/40ac3cbbe7365e6b89e3 to your computer and use it in GitHub Desktop.
Template Cache service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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