使用 $timeout 注意

$scope destroy 時要 cancel,因為不會自動取消呼叫,若固定周期呼叫則會持續呼叫
$scope.timer = $timeout($scope.onTimeout, 10000);
 $scope.$on(
        "$destroy",
        function (event) {
            $timeout.cancel($scope.timer);
        }
    );

留言

熱門文章