Dealing with dynamic templates on directives is not a common task with AngularJS, because we can change the style of a view directly with CSS, but often this is a technique that can help us to implement a different direction, and leave us with different and flexible templates. It is always very helpful to have different options at hand.
In this chapter, we will see an easy way to implement this technique with AngularJS in two different stages, the first using an inline template inside the directive using the $compile function, and another using external templates.
This chapter is somewhat conceptual and may seem to escape the cookbook format, but here we present some features and techniques that are related to all the recipes in this chapter.
The total content is a powerful way to deal with directives using dynamic templates.