aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Minar2013-06-10 12:54:41 -0700
committerIgor Minar2013-06-10 13:10:38 -0700
commitce6c2b207272302f075fb1ef1961a087896f01e1 (patch)
tree62a16043f7a8f2927ef3b6a0c2432959b5af8121
parent3e94a2c54d7ddfaca7518031de5e6297c11add17 (diff)
downloadangular.js-ce6c2b207272302f075fb1ef1961a087896f01e1.tar.bz2
chore(docs): fix memory leak in example embed code
we need to sever the link between the main root scope and the example root scope - this is only needed because we are embedding one app in the other.
-rw-r--r--src/bootstrap/bootstrap-prettify.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/bootstrap/bootstrap-prettify.js b/src/bootstrap/bootstrap-prettify.js
index 026587a2..406995e0 100644
--- a/src/bootstrap/bootstrap-prettify.js
+++ b/src/bootstrap/bootstrap-prettify.js
@@ -183,7 +183,9 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
return {
terminal: true,
link: function(scope, element, attrs) {
- var modules = [];
+ var modules = [],
+ embedRootScope,
+ deregisterEmbedRootScope;
modules.push(['$provide', function($provide) {
$provide.value('$templateCache', $templateCache);
@@ -209,10 +211,12 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
}
}, $delegate);
}]);
- $provide.decorator('$rootScope', ['$delegate', function(embedRootScope) {
- docsRootScope.$watch(function embedRootScopeDigestWatch() {
+ $provide.decorator('$rootScope', ['$delegate', function($delegate) {
+ embedRootScope = $delegate;
+ deregisterEmbedRootScope = docsRootScope.$watch(function embedRootScopeDigestWatch() {
embedRootScope.$digest();
});
+
return embedRootScope;
}]);
}]);
@@ -223,6 +227,12 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
event.preventDefault();
}
});
+
+ element.bind('$destroy', function() {
+ deregisterEmbedRootScope();
+ embedRootScope.$destroy();
+ });
+
angular.bootstrap(element, modules);
}
};