Wrapping Third-Party Libraries in AngularJS
One of my favorite things about AngularJS is that it provides several useful mechanisms for wrapping third-party code. That said, there are so many ways to do it that it’s not always obvious which one to use. Should I call this third-party library directly from a controller? Abstract it into a directive? Wrap it in a service? Or some combination of all three? The answer, as you’ve probably already guessed, is “it depends.” Let’s take a look at some examples.