angularjs - $timeout.cancel not working -
i trying cancel $timeout in code snippet shown below, doesn't seems working.
var trial=1; $scope.trialtimeout = $timeout(countdowntime,0); function countdowntime(){ $timeout(function(){ trial++; console.log("countdowntime"); if(trial>2) { callme(); } countdowntime(); },1000) } function callme(){ console.log("this "+$timeout.cancel($scope.trialtimeout)); //$timeout.cancel(trialtimeout); }
when log$timout.cancel($scope.trialtimeout)
returns false means not cancelling the timeout. $scope.trialtimeout gives promise object still, unable cancel timeout.
Comments
Post a Comment