【发布时间】:2014-08-02 18:43:21
【问题描述】:
我正在使用 Angular 的超时以用户指定的时间间隔刷新图像的内容。当该间隔太短而无法加载图像时(例如 1 秒),每个后续请求都会取消前一个请求,从而导致图像永远不会刷新。
我希望完成当前请求并取消后续请求,直到请求冲突时该请求完成,而不是这种行为。我该怎么做?
处理刷新的代码:
$scope.setImagePath = function() {
$scope.imagePath = $scope.camera.endpoint + '?decache=' + Math.random();
};
$scope.setImagePath();
$scope.refreshOnInterval = function() {
$timeout(function() {
$scope.setImagePath();
$scope.refreshOnInterval();
}, $scope.refresh);
};
$scope.refreshOnInterval();
【问题讨论】:
标签: javascript angularjs