AngularJS - How to cancel a promise? [duplicate]
Usually for this case people use ng-model-options={debounce: 100}
.
https://docs.angularjs.org/api/ng/directive/ngModelOptions
anyway you can reject promise.
I think you want to use a debounce
technique in this case?
see:
- https://docs.angularjs.org/api/ng/directive/ngModelOptions
<input type="text" class="form-control" data-ng-model="query" data-ng-change="ctrl.search(query)" placeholder="Search" ng-model-options="{ debounce: { 'default': 500, 'blur': 0 } }" />
Like this: $q.reject(response);
Although technically I believe that the above commenter is correct, you're actually rejecting the promise and not really canceling it.