Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$timeoutangularjs アプリのいずれかのページの情報を定期的に更新するために使用します。$timeoutユーザーがこのページから離れたときにキャンセルしたいと思います。それを行う簡単な方法はありますか?
$timeout
わかりました、掘り下げた後に解決策を見つけました:
$scope.$on('$destroy', function() { $timeout.cancel(timeout); });
または、Angular 1.5 の新しいコンポーネント構文の場合:
this.$onDestroy = function() { if (timeout) { $timeout.cancel(timeout); } }