Directive's controller function
In this chapter, we have seen a different way to declare a directive to manipulate the DOM. In the previous chapter, we explored different ways of working with the directive's properties. In this example, we will declare an external controller to the directive without writing any code within the directive.
Getting ready
Using external controllers is very common in applications that have many customized directives. They help us separate the content in a more practical way, in the same behavior of the directives template. With separated controllers, we can use many AngularJS resources, such as services and other features.
This example serves to illustrate the flexibility that directives have.
We will use the same code as the previous example, but this time, we will place the controller's code in a separate file.
How to do it…
- Replace the controller's code with the following highlighted code:
'use strict'; /** * @ngdoc function...