admin管理员组

文章数量:1287591

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 
}

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 
}
Share Improve this question edited Jan 6, 2015 at 13:44 augustoccesar 6669 silver badges30 bronze badges asked Jan 6, 2015 at 13:31 sagar43sagar43 3,4643 gold badges31 silver badges49 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 7
<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
}

本文标签: javascriptGet value of textbox on ngkeypress in AngularjsStack Overflow