diff --git a/src/ng/compile.js b/src/ng/compile.js
index cff8fb38516c..e5e430d76c0a 100644
--- a/src/ng/compile.js
+++ b/src/ng/compile.js
@@ -1177,7 +1177,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
var clone = transcludeFn(transcludedScope, cloneFn, controllers, previousBoundTranscludeFn, futureParentElement);
if (scopeCreated && !elementTransclusion) {
- clone.on('$destroy', function() { transcludedScope.$destroy(); });
+ futureParentElement.on('$destroy', function() { transcludedScope.$destroy(); });
}
return clone;
};
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index 2a0d84d04150..7c3f8397db1f 100755
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -5551,6 +5551,64 @@ describe('$compile', function() {
});
});
+
+ it('should not leak memory when a directive removes the element containing the transclude directive', function() {
+
+ module(function() {
+ directive('toggle', function() {
+ return {
+ transclude: true,
+ template:
+ '