【发布时间】:2017-06-22 16:32:17
【问题描述】:
以下是我用来更新列表计数的代码, 起初它在计数时工作正常,但随着计数改变值轻弹。 例如:如果 count 一开始是 3,然后 count 更新为 4。count 变量在 3 和 4 之间闪烁。
setInterval(function () {
if ($scope.listing != undefined && $scope.listing != null) {
$rootScope.countsData = $scope.listing.length;
} else {
$rootScope.countsData = 0;
}
}, 2000);
【问题讨论】:
-
格式化/缩进你的代码,它是不可读的。
-
那么当
count改成4的时候,你还想看3吗?为什么? -
我不想看到 3,但它同时显示了 3 和 4。我只想看 4 个。
标签: javascript angularjs angularjs-scope setinterval flicker