值超过100时如何使用AngularJS初始化输入[range]的值 [英] How to initialize the value of an input[range] using AngularJS when value is over 100
问题描述
我尝试使用AngularJS初始化滑块,但是当该值超过100时,光标会显示100.
I try to initialize a slider using AngularJS, but the cursor show 100 when the value is over 100.
使用以下代码将值150设置在[50,150]范围内会失败:
Setting the value 150 in a range [50,150] fails with this code :
<html ng-app="App">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script>
angular.module('App', ['App.controllers']);
angular.module('App.controllers', []).controller('AppController', function($scope) {
$scope.min = 50;
$scope.max = 150;
$scope.value = 150;
});
</script>
</head>
<body ng-controller="AppController" >
{{min}}<input ng-model="value" min="{{min}}" max="{{max}}" type="range" />{{max}}<br/>
value:{{value}}
</body>
</html>
光标位置错误(显示100而不是150). 如何将光标显示在正确的位置?
The cursor is badly placed (it show 100 instead of 150). How to display the cursor to its correct place ?
有关发生的情况的说明可以在此论坛
An explanation of what occurs could be on this forum
更新
该错误报告为问题#6726
Update
This bug is reported as issue #6726
更新
Update
The issue #14982 is closed by the Pull Request 14996 and solve the issue see answer.
推荐答案
由于此提交,初始代码给出了预期的结果.
使用版本 1.6.0 允许原始代码以正确显示滑块:
Since this commit, the initial code give the expected result.
Using release 1.6.0 allow to original code to show slider correctly :
<html ng-app="App">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.min.js"></script>
<script>
angular.module('App', ['App.controllers']);
angular.module('App.controllers', []).controller('AppController', function($scope) {
$scope.min = 50;
$scope.max = 150;
$scope.value = 150;
});
</script>
</head>
<body ng-controller="AppController" >
{{min}}<input ng-model="value" min="{{min}}" max="{{max}}" type="range" />{{max}}<br/>
value:{{value}}
</body>
</html>
这篇关于值超过100时如何使用AngularJS初始化输入[range]的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!