[英]function doesn't return variable
this really easy and stupid question but I'm already stuck on 2 two days. 这个非常简单而愚蠢的问题,但是我已经被困在两两天了。 I have to receive data from server or whatever and I wrote easy function, so this guy 我必须从服务器等接收数据,并且编写了简单的函数,所以这个家伙
$scope.myTar = function() {
return 5;
};
$scope.identity = angular.identity;
$scope.range = function(min, max, step){
step = Math.floor((max+5)/3);
var input = [];
for (var i = min; i < max+5; i += step)
input.push(i);
input.push($scope.myTar());
return input;
};
and this guy 这个家伙
<div ng-repeat="n in range(0, gauge.gaugeData.target) |orderBy:identity">
<div ng-class="{ 'numberGaugeBar-goal': n == myTar() }"></div>
<div class="numberGaugeNumbers-hashHolder"></div>
<div class="numberGaugeNumbers-numberHolder"> {{n}} </div>
</div>
return for me digit 5 and pushing it into my range 为我返回数字5并将其推入我的范围
if I use this guy 如果我用这个家伙
$scope.myTar = function(target) {
$log.debug('['+target+']')
};
it returns me on console all my necessary values but if I use this guy 它会在控制台上将我所有必要的值返回给我,但是如果我使用此人
$scope.myTar = function(target) {
return target;
};
and 和
<div ng-repeat="n in range(0, gauge.gaugeData.target)|orderBy:identity">
<div ng-class="{ 'numberGaugeBar-goal': n == myTar(gauge.gaugeData.target) }"></div>
<div class="numberGaugeNumbers-hashHolder"></div>
<div class="numberGaugeNumbers-numberHolder"> {{n}} </div>
</div>
it returns me in console target is undefined, what's wrong? 它返回我在控制台目标是未定义的,怎么了?
the gaugeData is coming from other function LoadGaugesData I tried to input this part of code to myTar function but it still shows me same thing. gaugeData来自其他函数LoadGaugesData,我试图将这部分代码输入到myTar函数中,但仍然显示出相同的内容。 Also as you can see my range is using gaugeData.target and it works fine... this is part of it 您还可以看到我的范围正在使用gaugeData.target,并且效果很好...这是其中一部分
for (var idx in $scope.sectionDescriptives.scoreSections) {
section = $scope.sectionDescriptives.scoreSections[idx];
for (var gaugeIdx in section.gauges) {
var gauge = section.gauges[gaugeIdx];
var gaugeData = $scope.getGaugeData(gauge.id);
gauge.gaugeData = gaugeData;
gauge.target = gaugeData.target;
section.gauges[gaugeIdx].gaugeData = $scope.getGaugeData(gauge.id);
}}
for stupid question, stupid answer 对于愚蠢的问题,愚蠢的答案
I inserted max in my push function inside range like this 我在这样的范围内的push函数中插入了max
$scope.range = function(min, max, step){
step = Math.floor((max+5)/3);
var input = [];
for (var i = min; i < max+5; i += step)
input.push(i);
input.push(**max**);
return input;
};
thanks, for advice to check every step in debugger 谢谢,为检查调试器的每一步提供建议
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.