angularjs cancel resource request

Its a only trick which works for me very well:

Here is your function in controller which get the search results by submitting a form:

var methodCallCounter = 0;

$scope.getMyResults = function (){
     ++methodCallCounter;
     // Calling your service here and getting data
    Service.getResults({search: $scope.searchData, counter:methodCallCounter}, function (response) {
        if(methodCallCounter == response.counter){
            // Show your search results to user
        }else{
          // Do nothing, you can remove this else block
       }
    });
}

The idea is
- Use a counter variable in method call
- Send this counter variable with request
- Return same counter variable in response from server
- Match value of both counter value (client side and response)
- If value of both are same show results
- Else do nothing

Any doubts, please ask in comments.