Elliott Coe Elliott Coe - 1 year ago 576
AngularJS Question

Angular ng-keyup not working when calling a function

I've got this code:

<input type="text" ng-model="keywords" ng-keyup="search()">

It doesn't call the search function where as, if I do ng-click="search()" it does work. Why is this?

Answer Source

ng-keyup works perfectly fine for me. See this fiddle for an example: http://jsfiddle.net/r74a5m25/


<div ng-controller="MyCtrl">
    <input ng-model="testModel" ng-keyup="search()"/>

function MyCtrl($scope, $log) {

    $scope.search = function() {

Make sure you have an up to date version of angular in order to use ng-keyup. It looks like it has been available since version 1.0.8.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download