Angular directives allow us to extend the HTML syntax in a very powerful way—by adding new attributes and elements. This allows us to create components that feel native: from date and time pickers to data grids, charts, and visualizations.
Such components can then be reused without adding initialization code to our controllers. We simply tell the component what model it should bind to and it will automatically update its appearance to reflect any changes in the model.
In this recipe, we're going to make a chart directive using Flot to draw our chart. In the process, we will learn about some of the many powerful features of Angular directives.
We need to download Flot from http://www.flotcharts.org/ and extract the ZIP archive into our recipe directory, creating a sub-directory called flot
.