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