title: Cancel previous $http request only
body: <p>I have drop down whcih support search from server.. now on search start i bind change event to get terms from input for send request to server </p>
  
  <p>now it keep sending call to server when user is typing so I made some code so cancel previous calls if user is typing and send only the last request. 
  Here is method which called when user type</p>
  
  <pre><code>var currentAjax = null;
  var canceller = $q.defer();
  var cancel = function (reason) {
      canceller.resolve(reason);
  };
  $scope.callAjax = function (isSearch) {
    if ($scope.ajaxOptions) {
      if (currentAjax != null) {
          console.log("here");
          currentAjax.cancel("user cancel");
      }
      currentAjax = null;
      $scope.isLoading = true;
      if (isSearch) {
          $scope.inputModel = [];
      }
      var _request = {};
      _request.url = '';
      _request.method = 'POST';
      // _request.headers = {'Content-Type': 'JSON'}
  
      if ($scope.ajaxOptions.url) {
          _request.url = $scope.ajaxOptions.url;
      }
  
      if ($scope.ajaxOptions.method) {
          _request.method = $scope.ajaxOptions.method;
      }
  
      if ($scope.ajaxOptions.headers) {
          _request.headers = $scope.ajaxOptions.headers;
      }
  
      _request.data = $scope.ajaxOptions.prepareRequest($scope.getParams());
      _request.timeout = canceller.promise;
  
      var promise = $http(_request).
      success(function (data, status, headers, config) {
          currentAjax = null;
          $scope.isLoading = false;
          // some code 
      }).
      error(function (data, status, headers, config) {
          $scope.isLoading = false;
      });
  
      currentAjax = {
          promise: promise,
          cancel: cancel
      };
   }
  }
  </code></pre>
  
  <p>It done cancel request but it also cancel the last one also how can i prevent that suppose user type "angul"
  it should cancle request for "a","an","ang","angu" only not for "angul" ..</p>
  
  <p>here is working <a href="http://plnkr.co/edit/bfa0sqIRKWV6qZCZuFmS?p=preview" rel="nofollow">plunker</a> </p>
  
  <p>will find this method in <strong>isteven-multi-select-twinked.js</strong> <strong>line no:615</strong> </p>