Commit d1dd7e35 authored by Sam Saccone's avatar Sam Saccone

typescript-angular: Fix directive memory leak

parent ee1887e2
...@@ -45,6 +45,7 @@ var todos; ...@@ -45,6 +45,7 @@ var todos;
return { return {
link: function ($scope, element, attributes) { link: function ($scope, element, attributes) {
element.bind('blur', function () { $scope.$apply(attributes.todoBlur); }); element.bind('blur', function () { $scope.$apply(attributes.todoBlur); });
$scope.$on('$destroy', function () { element.unbind('blur'); });
} }
}; };
} }
......
...@@ -10,6 +10,7 @@ module todos { ...@@ -10,6 +10,7 @@ module todos {
return { return {
link: ($scope: ng.IScope, element: JQuery, attributes: any) => { link: ($scope: ng.IScope, element: JQuery, attributes: any) => {
element.bind('blur', () => { $scope.$apply(attributes.todoBlur); }); element.bind('blur', () => { $scope.$apply(attributes.todoBlur); });
$scope.$on('$destroy', () => { element.unbind('blur'); });
} }
}; };
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment