角度输入在最小值和最大值以内小数时无效



我遇到了一个奇怪的问题,我不明白为什么会发生这种情况......

我使用的是 Angular 1.6.1,当输入框的最大值和最小值之间时,我的输入无效。这似乎只发生在我的值是带有小数步的小数时。我已经在Chrome和Edge上对其进行了测试,它做了同样的事情。我尝试在谷歌上搜索它,但找不到任何相对的东西。

var myApp = angular.module('myApp', []);
myApp.controller('MyCtrl', function($scope) {
  $scope.Prices = {
    "Net": {
      "min": 0.00,
      "max": 9999.99
    }
  };
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div ng-app="myApp">
  <div ng-controller="MyCtrl">
    <form name="priceForm" novalidate>
      <div class="form-group" ng-class="{'has-error': priceForm.NetMax.$invalid && priceForm.NetMax.$dirty }">
        <label>Max Price:</label>
        <input class="form-control" name="NetMax" type="number" min="0.00" step="0.01" max="9999.99" ng-step="0.01" ng-model="Prices.Net.max" />
      </div>
    </form>
    <p>
      Try reducing the input to 9999.97. For some reason it is invalid.
    </p>
  </div>
</div>

将我的 Angular 版本更改为 1.6.4 似乎已经解决了这个问题。1.6.1 版中一定有错误

最新更新