Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何根据条件切换最小和最大输入值?_Javascript_Angularjs_Html_Input - Fatal编程技术网

Javascript 如何根据条件切换最小和最大输入值?

Javascript 如何根据条件切换最小和最大输入值?,javascript,angularjs,html,input,Javascript,Angularjs,Html,Input,我有两个input元素,其中定义了min和max。 我如何反转这些值,最好是在HTML或JS(角度)中 例如: <label> Width: <input type="number" min="10" max="100"> </label> <label> Height: <input type="number" min="50" max="400"> </label> 宽度: 高度:

我有两个
input
元素,其中定义了min和max。 我如何反转这些值,最好是在HTML或JS(角度)中

例如:

<label>
    Width:
    <input type="number" min="10" max="100">
</label>

<label>
    Height:
    <input type="number" min="50" max="400">
</label>

宽度:
高度:
如果用户在第一次输入中输入400,则第二次输入中的最小值和最大值将替换为
min=“10”max=“100”


换句话说,值必须是可互换的。

这里有一种方法来完成这项工作,使用一些额外的变量和

var myApp=angular.module('myApp',[]);
控制器('MyCtrl',['$scope',函数($scope){
$scope.minWidth=10;
$scope.maxWidth=100;
$scope.minHeight=50;
$scope.maxHeight=400;
$scope.update=函数(v){
if((v='w'&&$scope.width>$scope.maxWidth)| |(v='h'&&$scope.height>$scope.maxHeight)){
设reverseMax=$scope.maxWidth;
设reverseMin=$scope.minWidth;
$scope.maxWidth=$scope.maxHeight;
$scope.maxHeight=reverseemax;
$scope.minWidth=$scope.minHeight;
$scope.minHeight=reverseMin;
}
}
}]);

宽度:
{{minWidth}}-{{maxWidth}

高度: {{minHeight}}-{maxHeight}
您是否对此使用了任何类型的计算。如有,请邮寄