mardi 5 juillet 2016

Why binding to null not work when value of number input illegimate in AngularJs

See example here: http://ift.tt/29fU1Ru

<div ng-app>
  <div ng-controller="TodoCtrl">
      <input type="number" ng-model="value"  size="30" >
      <input type="button" ng-click="change()" class="btn-primary" value="TEST" >
  </div>
</div>

function TodoCtrl($scope) {
  $scope.change = function() {
    $scope.value = null
  }
}

When I type 10 into number input, click button, it turn to be empty.

However when I type a standalone e or . into number input, then click button, nothing happend. But $scope.value = 123 stills works.

Why?




Aucun commentaire:

Enregistrer un commentaire