title: how to daly send request after user stop typing using angularjs
body: <p>I am trying to find away to delay send request to WebApi after user stop typing using Angularjs 500 or 800 millisecond right now my code will send what user type and query data. I am thinking to delay send request but I don't know how to do it </p>
  
  <pre><code>                &lt;label for="exampleInputEmail1"&gt;search&lt;/label&gt;
                  &lt;input type="search" class="form-control user-search" data-ng-model="searchString" ng-keyup="search()" placeholder="Enter search here"&gt;
  &lt;div class="row"&gt;
      &lt;div ng-repeat="user in users" class="col-xs-6 col-lg-4"&gt;
          &lt;div&gt;
              &lt;h3&gt;{{user.FName +' '+ user.LName }}&lt;/h3&gt;
              &lt;p&gt;{{user.Title}}&lt;/p&gt;
  
          &lt;/div&gt;
  </code></pre>
  
  <p>HomeController</p>
  
  <pre><code>(function () {
      'use strict';
  
      var app = angular.module('finduser');
  
      var HomeController = function($scope, homeService) {
  
          $scope.searchString = "";
          $scope.currentPage = 1;
  
          var getUsers = function(searchString) {
              if (searchString) {
                  homeService.getUsers(searchString).then(function(data) {
                      $scope.users = data;
                  }, function(errMsg) {
                      console.log(errMsg);
                  });
              }
          } // /getUsers
  
  
      //search user                  
          $scope.search = function () {
              if ($scope.searchString.length &gt;= 2) {
                  getUsers($scope.searchString);
              }
          };// /search
  
      };// /HomeController
  
  
      app.controller('HomeController', ['$scope', 'HomeService', HomeController]);
  
  }());
  </code></pre>
  
  <p>Home Service </p>
  
  <pre><code>(function () {
      'use strict';
  
      var app = angular.module('finduser');
  
      var HomeService = function ($http) {
  
          var getUsers = function (search) {
              var str = search.replace('.', '~');
              var uri = 'api/values?value=' + encodeURIComponent(str);
  
              return $http.get(uri).then(function (response) {
                  return response.data;
              });
          };
  
          return {
              getUsers: getUsers
          };
      };
  
      app.factory('HomeService', ['$http', HomeService]);
  }());
  </code></pre>