Get text field value on ng-keypress in Angularjs

I want to get the value of a text field when I press a key.

I have html code like

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

And the JS code on my controller:

 $scope.myFunct = function (e) { var charCode = (e.which) ? e.which : e.keyCode; //i want here value of the textbox } 
+8
javascript angularjs
source share
1 answer
 <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 } 
+6
source share

All Articles