Is there any risk of doing that? Example:
if (someCondition) {
angular.element($window).bind('scroll', myHandler);
}
$scope.$on('$destroy', function() {
angular.element($window).unbind('scroll', myHandler);
});
Of course I could do
$scope.$on('$destroy', function() {
if (someCondition) {
angular.element($window).unbind('scroll', myHandler);
}
});
But I don't know if it's necessary. I've tested without the someCondition
condition and "it works", but I wanted to be sure.