【问题标题】:Angular Input invalid when decimal within min and max角度输入在最小值和最大值内时无效
【发布时间】:2017-09-03 03:06:44
【问题描述】:

我遇到了一个奇怪的问题,我不明白为什么会这样......

我使用的是 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>

【问题讨论】:

    标签: html angularjs validation input


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2019-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-09
      • 2013-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多