WinDev
WinDev

Reputation: 37

Angularjs onkeypress update value from input

<td>{{count}}</td>
<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.

Upvotes: 1

Views: 460

Answers (1)

Pankaj Parkar
Pankaj Parkar

Reputation: 136144

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.

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

Upvotes: 1

Related Questions