Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.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/8/linq/3.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_Jquery_Angularjs - Fatal编程技术网

Javascript 角度下拉菜单问题

Javascript 角度下拉菜单问题,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我正试图将信息从下拉菜单传递到var中,但不知道下一步该怎么做 var myApp=angular.module('myApp',[]); var nextVXPLevelValue=260; var currentLevel=10; var VXP=[2.41,2.50,1.80,1.56,1.43,1.35,1.30,1.26,1.23,1.20,1.1,1.17,1.16,1.14,1.13,1.13,1.12,1.11,1.11,1.10,1.09,1.09,1.08]; var i;

我正试图将信息从下拉菜单传递到var中,但不知道下一步该怎么做

var myApp=angular.module('myApp',[]);
var nextVXPLevelValue=260;
var currentLevel=10;
var VXP=[2.41,2.50,1.80,1.56,1.43,1.35,1.30,1.26,1.23,1.20,1.1,1.17,1.16,1.14,1.13,1.13,1.12,1.11,1.11,1.10,1.09,1.09,1.08];
var i;
var vxpResult=[];
var-iResult=[];
对于(i=0+(电流电平+1);i
这是我所能做到的,但我现在想更改手册

var currentLevel=10

作为我的下拉菜单的结果。有人能帮我一下吗

示例代码:

将所有代码移动到一个控制器中。然后将currentLevel暴露到$scope
$scope.currentLevel=10

然后可以将select元素的ng模型绑定到currentLevel,并在$scope.currentLevel上使用$watch来监视它的更改。在$scope.currentLevel发生任何更改时处理并更新$scope.vxp

$scope.$watch('currentLevel', function(newValue, oldValue) {
  // your vxp calculations here.  This code should set $scope.vxp at the end.
});

使用
ng change
了解下拉列表值何时更改,并手动更新其中的
currentLevel
非范围变量。
.

我想去掉静态“10”,并使其等于从下拉菜单中选择的任何内容将选择元素的ng模型绑定到currentLevel将完成该部分;)我已经编辑了我的答案,以提供一个示例JSFIDDLE谢谢你Travis,这就是我想要的,但是我注意到VXP专栏现在有一些问题。。。我会再看一遍的。。i、 e,如果我换到11级,然后回到10级,那就错了。我将为该级别的初始VXP添加另一个下拉菜单,在获得15个代表点之前,我无法投票。我正在工作,由于工作限制,无法访问我的fb登录,因此必须创建此帐户来提问。
$scope.$watch('currentLevel', function(newValue, oldValue) {
  // your vxp calculations here.  This code should set $scope.vxp at the end.
});