From eb681177e80dead7e6f3875575603f79fa87acec Mon Sep 17 00:00:00 2001 From: barbatus Date: Sat, 2 May 2015 17:06:55 +0300 Subject: [PATCH] Remove Blaze view handler on $scope destroy. --- modules/angular-meteor-template.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/angular-meteor-template.js b/modules/angular-meteor-template.js index 511286e7a..ee02cd1c9 100644 --- a/modules/angular-meteor-template.js +++ b/modules/angular-meteor-template.js @@ -63,8 +63,11 @@ angularMeteorTemplate.directive('meteorInclude', [ var name = attributes.meteorInclude || attributes.src; if (name && Template[name]) { var template = Template[name]; - Blaze.renderWithData(template, scope, element[0]); + var viewHandler = Blaze.renderWithData(template, scope, element[0]); $compile(element.contents())(scope); + scope.$on('$destroy', function() { + Blaze.remove(viewHandler); + }); } else { console.error("meteorTemplate: There is no template with the name '" + name + "'"); }