Simple AngularJS directive that adds a clear event for debounce.
Use the nl-debounce-clear
directive to supplement ngModelOptions with a clear
event for debounce
, which is triggered when a user clears the ngModel
field.
Interested in how debouce
works? Or how to define your own custom debounce
events? Then read the accompanying blogpost, AngularJS: Custom debounce events.
Just add nl-debounce-clear
to your ng-model
annotated fields to use clear
as an event for the debounce
and updateOn
properties of ng-model-options
.
<input type="text"
ng-model="name"
ng-model-options="{ updateOn: 'default clear', debounce: {'default': 1000, 'clear': 0} }"
nl-debounce-clear />
The clear
event is triggerend whenever a user decides to remove all content from a field.
Just use bower to install the package:
bower install --save angular-debounce-clear
In your AngularJS app, add angular-debounce-clear
as dependency:
angular.module('myApp', ['angular-debounce-clear'])
Now, you are able to use the nl-debounce-clear
directive as described under Usage.
Want to run a working example? Take these steps:
-
Clone the repo
git clone https://github.com/nolemmings/angular-debounce-clear ./debounce && cd ./debounce
-
Install necessary tooling
npm install
-
Run our example
gulp example