Skip to content

Commit

Permalink
chore(datepicker): Unregister parent watchers on $destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
deeg committed Jan 15, 2016
1 parent 64831b5 commit 973739b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
};

$scope.$on("$destroy", function() {
clearWatchListeners(watchListeners);
//Clear all watch listeners on destroy
while (watchListeners.length) {
watchListeners.shift()();
}
});
}])

Expand Down Expand Up @@ -776,7 +779,9 @@ function(scope, element, attrs, $compile, $parse, $document, $rootScope, $positi
$document.unbind('click', documentClickBind);

//Clear all watch listeners on destroy
clearWatchListeners(watchListeners);
while (watchListeners.length) {
watchListeners.shift()();
}
});
};

Expand Down Expand Up @@ -997,9 +1002,3 @@ function(scope, element, attrs, $compile, $parse, $document, $rootScope, $positi
}
};
});

function clearWatchListeners(watchListeners) {
for (var i = 0; i < watchListeners.length; i++) {
watchListeners[i]();
}
}

0 comments on commit 973739b

Please sign in to comment.