Currently in my demo, each time a user types something into an input field, a request is sent to the server. However, I would like only one request to be fired. For example, if the user types "abc," it currently fires three requests. Is there a way for the user to type continuously and have the request only fire after one second of stopping?
I am aware that inputs can be debounced with the ng-model-options directive, but this method waits until a certain amount of time has passed before firing the request. I want the user to be able to type without interruptions, but still have the request sent after a pause.
Below is the code snippet:
http://plnkr.co/edit/npiA2abAo5SEQFMMpKZO?p=preview
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope,$http) {
$scope.name = 'World';
$scope.keyupevt = function(){
console.log('xx')
$http.get("data.json")
.then(function(response) {
console.log(response)
});
}
});