0

So I know if the call is outside angularjs or it is async then we need $apply to update the angularjs scope.

What is the best practices to using $apply if I have many api/3rd party in my app? I always forgot or didn't know that api/plugin is async.

2
  • There is only one rule: always use $apply when updating Angular model outside from its scope.
    – remigio
    Commented Apr 27, 2013 at 9:55
  • Do you have some examples? Perhaps a little jsfiddle so we could rewrite it with a good pattern. Commented Apr 27, 2013 at 11:46

1 Answer 1

0

I would write a wrapper service for each lib that needs it, and encapsulate callbacks in angular promises, but remember it's only neccessary for asynchronous functions, if you call a synchronous external lib, this should work as expected without issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.