Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get value of textbox on ng-keypress in Angularjs

I want to get the value of the textbox on keypress.

I have html code like

<input style="width: 20%; float: right;" 
       ng-model="que.SelectedOptionsUID" 
       type="text" 
       ng-keypress="myFunct($event)"/>

And JS code on my controller:

$scope.myFunct = function (e) {
    var charCode = (e.which) ? e.which : e.keyCode;
    //i want here value of the textbox 
}
like image 766
sagar43 Avatar asked Jan 06 '15 13:01

sagar43


1 Answers

<input style="width: 20%; float: right;" 
       ng-model="que.SelectedOptionsUID" 
       type="text" 
       ng-keypress="myFunct($event, que.SelectedOptionsUID)"/>

Controller:

$scope.myFunct = function (e, myValue) {
    var charCode = (e.which) ? e.which : e.keyCode;        
    // do something with myValue
}
like image 68
devqon Avatar answered Nov 03 '22 22:11

devqon