Is there a way to implement a delay in sending a server request after the user stops typing in AngularJS, similar to debouncing? For example, if the user types "abc" and then stops for two seconds, the request is sent to the server.
Currently, every character typed triggers a request to the server. Here is an example code snippet:
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)
});
}
});
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
<input type="text" ng-keyup="keyupevt()" />
</body>