Answer the question
In order to leave comments, you need to log in
What is the difference between setTimeout and $timeout?
What is the difference between setTimeout and $timeout in angularjs?
Answer the question
In order to leave comments, you need to log in
The most important thing is that $timeout updates the scope (any data on the page will change), and a simple setTimeout will not update anything in the scope (the data on the page will be old as it was).
Most importantly, $timeout is by no means a substitute for setTimeout!!!
If you have a functionality that works with scope data and binds variables, then use $timeout, if you just need to execute something on a timeout (for example, do something once a second, then, after a second, again, and so further, but not related to updating the scope data), then use setTimeout. Tobish, $timeout starts a $digest-cycle and redraws the page - just imagine if you redraw the page every second.
use $timeout
in setTimeout() you will also have to handle $scope.$apply() , for binds
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question