I have this code inside a function that gets called every 1 or 2 minutes. It simply counts down from 60 to 0 (I've set 60 as the maximum number of iterations).

```
var timer = $interval(
   function (times: number) {
      var retry = 60 - times;
      $scope.retryMessage = "retry + " seconds";
   }, 1000, 60);

```

From what I can see the documentation is suggesting that the $interval must be cancelled but when can I do this? I assume that I cannot just add:

```
$interval.cancel(timer);

```

after this code.