Add a one second delay between query input and filtering history

This commit is contained in:
Siteshwar Vashisht
2013-10-22 23:45:32 +05:30
parent aed26f8c1e
commit 119dd06ea8
2 changed files with 12 additions and 1 deletions

View File

@@ -216,6 +216,17 @@ controllers.controller("historyController", function($scope, $http, $timeout) {
$scope.historyItems.splice(index, 1);
})};
var queryInputTimeout = null;
$scope.$watch("queryInput", function() {
if (queryInputTimeout){
$timeout.cancel(queryInputTimeout);
}
queryInputTimeout = $timeout(function() {
$scope.query = $scope.queryInput;
}, 1000);
});
$scope.fetchHistory();
});