title: AngularJS. Clear $timeout when invoking angular-ui modal
body: <p>I have several <code>$timeout</code> expressions in Modal controller</p>
  
  <pre><code>App.controller('ModalCtrl', function ($scope, $timeout) {
      for (var i = 0; i &lt; 10; i++) {
          (function () {
              var timer = $timeout(function () {
                  console.log('timer')
              }, 1000);
          })()
      }
  })
  </code></pre>
  
  <p>I need to clear all the timers when invoking the modal:</p>
  
  <pre><code>App.controller('MainCtrl', function ($scope, $modal, $timeout) {
      $scope.showMap = function () {
          var modal = $modal.open({
              templateUrl: 'modalap.html',
              controller: 'modalCtrl',
          })
  
          modal.result.then(function () { //fires when modal is resolving
          }, function () { //fires when modal is invoking
          });
      } })
  </code></pre>
  
  <p>How can I do that? </p>
  
  <p>PS Sorry for bad code formatting. I don't know why but I cant format it better. I duplicated code <a href="http://jsfiddle.net/VzQLU/1/" rel="noreferrer">here</a>: </p>