Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit b9288bf

Browse files
committed
Cleanup directives on $destroy
See Do event handlers need to be removed on directives when $destroy fires?http://stackoverflow.com/questions/19346129/do-event-handlers-need-to-be-removed-on-directives-when-destory-fires
1 parent dee006e commit b9288bf

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

dist/select.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ angular.module('ui.select', [])
9797
}
9898
});
9999

100+
scope.$on('$destroy', function() {
101+
$document.off('mousedown');
102+
});
103+
100104
// Move transcluded elements to their correct position on main template
101105
transcludeFn(scope, function(clone) {
102106
var transcluded = angular.element('<div>').append(clone);
@@ -203,6 +207,10 @@ angular.module('ui.select', [])
203207
}
204208
});
205209

210+
scope.$on('$destroy', function() {
211+
uiSelectCtrl.input.off('keydown');
212+
});
213+
206214
};
207215
}
208216
};

src/select.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ angular.module('ui.select', [])
9797
}
9898
});
9999

100+
scope.$on('$destroy', function() {
101+
$document.off('mousedown');
102+
});
103+
100104
// Move transcluded elements to their correct position on main template
101105
transcludeFn(scope, function(clone) {
102106
var transcluded = angular.element('<div>').append(clone);
@@ -203,6 +207,10 @@ angular.module('ui.select', [])
203207
}
204208
});
205209

210+
scope.$on('$destroy', function() {
211+
uiSelectCtrl.input.off('keydown');
212+
});
213+
206214
};
207215
}
208216
};

0 commit comments

Comments
 (0)