0
我正在使用角度,我无法让我的柜台工作。 我有这样的功能:如何在返回之前递增计数器而不传递回调函数?
$scope.statClass = function(summoner, key) {
var stat = 'stat-same';
if(shouldRevert(key)) {
summoner === 1 ? summoner = 2 : summoner = 1;
}
if(summoner === 1) {
if($scope.champData1[key] > $scope.champData2[key]) {
$scope.score1++;
stat = 'stat-bigger';
} else if ($scope.champData1[key] < $scope.champData2[key]) {
stat = 'stat-lower';
}
} else if(summoner === 2) {
if($scope.champData2[key] > $scope.champData1[key]) {
$scope.score2++;
stat = 'stat-bigger';
} else if ($scope.champData2[key] < $scope.champData1[key]) {
stat = 'stat-lower';
}
}
return stat;
};
,当我试图确定类格式化某种“格”块运行。 每次加载我的页面并显示{{score1}}或{{score2}}时,它将显示为'null'。 如何在返回统计之前增加分数值?
PS:我宣布$ scope.score1和2之外的功能。
我不认为这是显而易见从这个片段,为什么你的计数器不工作。你是否将'score1'和'score2'初始化为'0'? – Pete 2014-09-18 16:49:18
这可能是一个范围问题。 – 2014-09-18 17:00:17