aboutsummaryrefslogtreecommitdiffstats
path: root/docs/components
diff options
context:
space:
mode:
authorIgor Minar2013-06-10 12:54:41 -0700
committerIgor Minar2013-06-10 13:14:26 -0700
commit6c663154943e4c0c33c19026a7b500302bda29d4 (patch)
tree2e04bfd80620dd52023c42ab491b9ebb0c8bc722 /docs/components
parentb700aa9291409a94dbc01c6c945ab18391dd9afb (diff)
downloadangular.js-6c663154943e4c0c33c19026a7b500302bda29d4.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.
Diffstat (limited to 'docs/components')
-rw-r--r--docs/components/angular-bootstrap/bootstrap-prettify.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/docs/components/angular-bootstrap/bootstrap-prettify.js b/docs/components/angular-bootstrap/bootstrap-prettify.js
index cbe7b53f..f1c3fccb 100644
--- a/docs/components/angular-bootstrap/bootstrap-prettify.js
+++ b/docs/components/angular-bootstrap/bootstrap-prettify.js
@@ -185,7 +185,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);
@@ -212,10 +214,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;
}]);
}]);
@@ -227,6 +231,11 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
}
});
+ element.bind('$destroy', function() {
+ deregisterEmbedRootScope();
+ embedRootScope.$destroy();
+ });
+
angular.bootstrap(element, modules);
}
};