user3154990 user3154990 - 9 months ago 48
HTML Question

Why event.keyCode not working in ng-keyup?

ng-keyup="if (event.keyCode == 13) setCurrent(pagination.navigatevalue);"

this works fine with onkeyup but not ng-keyup..Am I missing anything


Event object is available as $event in ng event directives expressions. Another problem with your code is that you can't use control statements like if-else. Simple solution is to use logical AND operator &&.

Your code will look like this:

ng-keyup="$event.keyCode == 13 && setCurrent(pagination.navigatevalue)"