title: Cancelling $interval with promise after condition is met with Angular timer
body: <p>I am having a difficult time getting my $interval service to cancel.  I am not entirely sure what it is that I am missing.</p>
  
  <p>I have initialed a counter that is counting down a counting property. <b> $scope.sessionCounter </b></p>
  
  <pre><code>           $scope.sessionCounter = 5;
  
              var intializeSessionCounter = function () {
                  $scope.sessionTime();
                  $interval(function () {
                      $scope.sessionCounter--;
                      if ($scope.sessionCounter &gt; 1) {
                          console.log('timedown', $scope.sessionCounter);
                      }
                      else {
                          $scope.showSessionTimeoutWarningModal();
                          $scope.stop();
  
  
                      }
                  }, 1000);
              }
              intializeSessionCounter();
  </code></pre>
  
  <p>Above everything is working fine as it goes through the if statement.  When $scope.sessionCounter goes to <b>1</b> I hit the else statement.  The modal that I want to open pops up.  Next<b> $scope.stop </b> is hit and <b>$interval.cancel(null) </b> is read.  However, nothing cancels and my modal continues to reopen as <b>$interval </b> continues to run into negative numbers.  </p>
  
  <pre><code>            $scope.stop = function () {
                  $interval.cancel(null);
              }
  </code></pre>