O'Reilly logo

AngularJS Directives by Alex Vanston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Summary

So, in the end, the compile function is awesome. It's also rarely needed. Most of the time, your link function will handle all of the heavy lifting for you, and adding in the compile option just creates unnecessary complexity within your code. On the other hand, when you need to be able to manipulate the template element before binding to the scope, or want to conditionally apply the linker function as the data changes, compile offers you that option. Next chapter we'll dive into scoping, a helpful way to ensure your data is properly linked, yet still modular, both inside and outside your directives.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required