I'm trying to reset two scopes that defined before on an "esc" keyup event but it apparently does not work when I check out them. $document is defined on my controller's dependencies.
Here is what I've tried:
$document.bind('keyup', function (event) {
if (event.keyCode == 27) {
$scope.currentPage = false;
}
});
jQuery(document).keyup(function (event) {
if (event.keyCode == 27) {
$scope.currentPage = false;
}
});
Use $scope.$apply(function() { ... }); to force the Angular digest cycle to run.
Your code will be:
$document.bind('keyup', function (event) {
if (event.keyCode == 27) {
$scope.$apply(function() {
$scope.currentPage = false;
});
}
});