【发布时间】:2013-09-04 10:27:41
【问题描述】:
如果后端调用需要更长的时间,我会创建一个显示消息的函数...
我试图观察 $locationChangeSuccess 事件......
$scope.$on('$locationChangeStart', function (event, newLoc, oldLoc){
deferred = $timeout(function() {
alert('takes more that 10 sec!!!');
}, 10000);
});
$scope.$on('$locationChangeSuccess', function (event, newLoc, oldLoc){
console.log('Cancelled: ' + $timeout.cancel(deferred));
});
它不起作用,因为 $locationChangeSuccess 事件在 $location.path(...) 之后立即触发(没有等待响应)
您知道响应返回后立即触发的任何事件吗?
谢谢
【问题讨论】:
-
你想在需要很长时间时取消还是只显示一条消息?
标签: angularjs time error-handling timeout request