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

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

问题描述

我尝试使用 AngularJS 初始化滑块,但是当值超过 100 时光标显示 100.

I try to initialize a slider using AngularJS, but the cursor show 100 when the value is over 100.

在 [50,150] 范围内设置值 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 ?

这个论坛

更新
此错误报告为问题 #6726

更新
问题 #14982 已由 拉取请求 14996 并解决问题,请参阅 答案.

Update
The issue #14982 is closed by the Pull Request 14996 and solve the issue see answer.

推荐答案

自此 commit,初始代码给出了预期的结果.
使用发布 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 初始化 input[range] 的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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