title: angularJS stop the $interval call after an IF condition is true
body: <p>I am trying to reload my models every 5000 milliseconds for which I am using the AngularJS $interval function to invoke my init () method. I want to stop reloading the models after all the values in a list are "COMPLETED" or no value in a given list is either Processing. Any Clue how to achieve this ?</p>
  
  <pre><code> function DeliveriesController(deliveriesService, $interval){
  
      var vm = this;
      vm.defaultWorkspace = 'HOT_POT';
      vm.currentWorkspace = vm.defaultWorkspace;
  
      vm.priorities = [];     // priorities are based the names of each workspace.
                              // So call the workspace end point from the workspaceService
                              // to get a list of all workspace. Then assign it to the priorities.
      vm.deliveries = {};
      vm.selectTab = selectTab;
      vm.retryDelivery = retryDelivery;
      vm.removeDelivery = removeDelivery;
      vm.downloadLog = downloadLog;
      vm.getDeliveryDdex = getDeliveryDdex;
      vm.refresh = refresh;
  
      $interval(init, 5000);
      return init();
  
  
      /**
       * Get the list of deliveries and initialize the model
       */
      function init(){
          deliveriesService.getDeliveries(vm.currentWorkspace).then(function (responseValues){
              vm.deliveries = responseValues;
          });
      }
  
      function refresh(){
          init();
      }
      function selectTab(workspace){
          vm.currentWorkspace = workspace;
          init();
      }
  </code></pre>