aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/AngularPublic.js1
-rw-r--r--src/service/cacheFactory.js7
-rw-r--r--src/widgets.js23
3 files changed, 17 insertions, 14 deletions
diff --git a/src/AngularPublic.js b/src/AngularPublic.js
index 4d94e901..105059dc 100644
--- a/src/AngularPublic.js
+++ b/src/AngularPublic.js
@@ -87,6 +87,7 @@ function ngModule($provide, $injector) {
$provide.service('$routeParams', $RouteParamsProvider);
$provide.service('$rootScope', $RootScopeProvider);
$provide.service('$sniffer', $SnifferProvider);
+ $provide.service('$templateCache', $TemplateCacheProvider);
$provide.service('$window', $WindowProvider);
}
diff --git a/src/service/cacheFactory.js b/src/service/cacheFactory.js
index ccc69313..2d4c87cf 100644
--- a/src/service/cacheFactory.js
+++ b/src/service/cacheFactory.js
@@ -150,3 +150,10 @@ function $CacheFactoryProvider() {
return cacheFactory;
};
}
+
+function $TemplateCacheProvider() {
+ this.$get = ['$cacheFactory', function($cacheFactory) {
+ return $cacheFactory('templates');
+ }];
+}
+
diff --git a/src/widgets.js b/src/widgets.js
index fdbc884c..227ab167 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -90,15 +90,13 @@ angularWidget('ng:include', function(element){
this.directives(true);
} else {
element[0]['ng:compiled'] = true;
- return ['$http', '$cacheFactory', '$autoScroll', '$element',
- function($http, $cacheFactory, $autoScroll, element) {
+ return ['$http', '$templateCache', '$autoScroll', '$element',
+ function($http, $templateCache, $autoScroll, element) {
var scope = this,
changeCounter = 0,
releaseScopes = [],
childScope,
- oldScope,
- // TODO(vojta): configure the cache / extract into $tplCache service ?
- cache = $cacheFactory.get('templates') || $cacheFactory('templates');
+ oldScope;
function incrementChange() { changeCounter++;}
this.$watch(srcExp, incrementChange);
@@ -135,14 +133,14 @@ angularWidget('ng:include', function(element){
releaseScopes.pop().$destroy();
}
if (src) {
- if ((fromCache = cache.get(src))) {
+ if ((fromCache = $templateCache.get(src))) {
scope.$evalAsync(function() {
updateContent(fromCache);
});
} else {
$http.get(src).on('success', function(response) {
updateContent(response);
- cache.put(src, response);
+ $templateCache.put(src, response);
}).on('error', clearContent);
}
} else {
@@ -575,14 +573,11 @@ angularWidget('ng:view', function(element) {
if (!element[0]['ng:compiled']) {
element[0]['ng:compiled'] = true;
- return ['$http', '$cacheFactory', '$route', '$autoScroll', '$element',
- function($http, $cacheFactory, $route, $autoScroll, element) {
+ return ['$http', '$templateCache', '$route', '$autoScroll', '$element',
+ function($http, $templateCache, $route, $autoScroll, element) {
var template;
var changeCounter = 0;
- // TODO(vojta): configure the cache / extract into $tplCache service ?
- var cache = $cacheFactory.get('templates') || $cacheFactory('templates');
-
this.$on('$afterRouteChange', function() {
changeCounter++;
});
@@ -601,7 +596,7 @@ angularWidget('ng:view', function(element) {
}
if (template) {
- if ((fromCache = cache.get(template))) {
+ if ((fromCache = $templateCache.get(template))) {
scope.$evalAsync(function() {
updateContent(fromCache);
});
@@ -611,7 +606,7 @@ angularWidget('ng:view', function(element) {
// ignore callback if another route change occured since
if (newChangeCounter == changeCounter)
updateContent(response);
- cache.put(template, response);
+ $templateCache.put(template, response);
$autoScroll();
}).on('error', clearContent);
}