Clearing debounce on ng-model-options

I have an input configured with debounce in the model parameters, for example:

<input type="text" ng-model="searchTerm" ng-keypress="$event.which===13 && search(searchTerm)" ng-model-options="{debounce: 1000}"> 

Then I have a clock setting for the model value:

 $scope.$watch('searchTerm', function (term) { if (!term || term.length === 0) { $scope.clearSearch(); } if (term.length > 3) { $scope.search(term); } }); 

As you can see from the input declaration, I configured the ng-keypress event to call my search function if the enter key is pressed.

Is there a way to clear debounce so that the [enter] key will remove the debounce, allowing you to immediately update the search string?

thanks

+5
source share

Source: https://habr.com/ru/post/1236148/


All Articles