Ionic continue get data from webservice after change page


I made this function for get data from a rails webservice, and insert new value in the chart every second. This works well, but when I click in back to return to other screen, I see in rails terminal, the ionic application continue get data. I want when the screen changes (and controller), this get stops.

My code:

var countUp = function() {

   if (experimentStatus) {
      $scope.timeInMs+= 1000;
      acquisition_time = $scope.timeInMs / 1000;

      .success(function(response) {
      $timeout(countUp, 1000);

What I have to do, to finish this function after change page?