In some cases, System has to provide suggestions to user while user typing. Sending request for each and every request to server will be overhead. So sending request to server when user finishes typing will give good performance. We can detect whether user typing or finished his typing by delaying the ng-change event.


Call function with ng-change. displayName function will be triggered when user changes input
<input ng-change="displayName()" ng-model="name"/>
<div ng-bind="name1"></div>


Use $timeout to delay the function
function myCtrl($scope, $timeout) {
     $scope._timeout  = null;
     $ = 'sri';
     $scope.FilterByName = function () {
        if($scope._timeout){ //if there is already a timeout in process cancel it
        $scope._timeout = $timeout(function(){
           $scope._timeout = null;
           $scope.name1 = $;



Follow this blog by Email

Popular Posts