Last Updated: October 17, 2017
· ydeshayes

Asynchronous on-change function execution with AngularJS

On-change event is awesome, but when you have a huge things to do when this event happend (for example when the user write something in an input) the GUI will freeze like hell !

I write a directive to do that work asynchronously :


I use $interval angularjs function (setInterval with an $apply at the end) to control a tick. On every tick I check if I have to run the function.

To run the function on the right context I use a watcher that I disable right after his execution.

The goal I try to achieve is to use promise so that the function don't run concurently, but for now this solution work fine.

Say Thanks