Tom Maitland

Creates digital things at Agency. WordPress developer. Web designer. Communicates for UN Youth Australia.

Debounced, delayed or throttled model updates in Angular 1.2+

21 November 2013

The Angular JS 1.2 update significantly changed how Angular JS handles event binding. The update meant that debouncing/delaying/throttling directives like ngAmpereDebouce¬†or error out. Googling around for updated solutions didn’t yield much so I mashed together a nice solution using some code from this StackOverflow question. All resulted in this – a debounce/delay/throttled model update script for Angular JS 1.2+.

The directive delays Angular model updates until an input stops changing for 1000ms, it will also push an update on blur.