Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
187
rated 0 times [  191] [ 4]  / answers: 1 / hits: 25086  / 10 Years ago, wed, september 17, 2014, 12:00:00

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?


More From » angularjs

 Answers
110

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



Code:



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


function MyCtrl($scope, $log) {

$scope.search = function() {
alert('test');
};
}





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.


[#69417] Tuesday, September 16, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gilbertomaximilianod

Total Points: 208
Total Questions: 96
Total Answers: 111

Location: Northern Mariana Islands
Member since Wed, Feb 24, 2021
3 Years ago
;