The bulk of the answer is $ templateCache . Exposure:
var myApp = angular.module('myApp', []);
myApp.run(function($templateCache) {
$templateCache.put('templateId.html', 'This is the content of the template');
});
Any of the html templates can be migrated to $templateCache, and the rest of our application will act as expected (no other changes are required)
local cache storage
, , . angular-local-storage .
, run()
local-storage,- , ...
- (
local-storage $templateCache)
.run([ 'localStorageService','$templateCache','$http',
function myAppConfig(localStorageService , $templateCache , $http) {
var templateKey = "TheRealPathToTheTemplate.tpl.html";
var template = localStorageService.get(templateKey);
if (!template) {
$http.get(templateKey)
.then(function(response) {
template = response.data;
localStorageService.add(templateKey, template);
$templateCache.put(templateKey, template);
});
} else {
$templateCache.put(templateKey, template);
}
}])
, , local-storage. "" , ... .
. / version . , .