Reputation: 24572
Given this code:
<body ng-keydown="key($event);">
$scope.key = function ($event) {
if (key == 13) {
document.getElementById("aButton").click();
}
}
When I run the code I am getting a message saying there is:
$apply already in progress
Can someone give me some advice on how I can fix my problem.
Upvotes: 0
Views: 36
Reputation: 5572
Try $timeout
$scope.key = function ($event) {
if ($event.which == 13) {
$timeout(function(){
document.getElementById("aButton").click();
})
}
}
Upvotes: 1