WinDev WinDev - 8 months ago 53
AngularJS Question

Angularjs onkeypress update value from input

<td><div class="col-xs-12"><input type="text" ng-keypress="count ='10'" ng-init="count=0"></div></td>

Its working but I want to put the input text value into the count= to display the input value in the {{count}}
So if I write 20 into the input box the {{count}} must be 20 etc. But I dont know how to put the input text value into the ng-keypress without adding extra javascript parts.

Answer Source

Put ng-model directive on input element, That will enable two way binding and remove ng-keypress which isn't make sense there to have it.

  <div class="col-xs-12">
     <input type="text" ng-model="count" ng-init="count=0">