user3154990 user3154990 - 2 years ago 121
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

Answer Source

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)"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download