AngularJS has a $timeout service which acts as a convenience wrapper around setTimeout.
Why is there no equivalent for setInterval?
AngularJS has a $timeout service which acts as a convenience wrapper around setTimeout.
Why is there no equivalent for setInterval?
Since $timeout is calls scope.apply
after each call it can get expensive. However creating a simple interval you can decide what watches and apply calls are needed to keep it clean.
For example, if you interval was running once every minute to check if the user's values had changed and optionally saving it if the values had been changed since the last check. Depending on how you write the code, you may never need to update the web page, so your interval
can get by without triggering an update.
That doesn't answer the question directly of why $interval isn't provided by default, but I suspect it is because since it is simple to create your own with you specific requirements, it is better to leave it open for you to enhance, instead of providing a default implementation that is too complex, or too inflexible.