值超过100时如何使用AngularJS初始化输入[range]的值 [英] How to initialize the value of an input[range] using AngularJS when value is over 100

查看:83
本文介绍了值超过100时如何使用AngularJS初始化输入[range]的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用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

更新
#14982 ./github.com/angular/angular.js/pull/14996"rel =" nofollow noreferrer>拉出请求14996 并解决问题,请参见

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆