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.

Making a chart component with Angular directives

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.