Avoid "$apply() already in progress" error