Creating our own directives

Now that we have already studied a bunch of built-in directives of a framework, it's time to create our own reusable components! First, we need to know how to register a new directive into our module.

Basically, it's the same process that we use for the controller; however, the directives require the creation of something called Directive Definition Object that will be used to configure the directive's behavior:

parking.directive("directiveName", function () {
  return {
  };
});

Our first challenge involves the creation of an alert component. Following this, there is an image of the component that we are going to create together step by step:

The original code consists of a group of elements associated with some styles. Our ...

Get AngularJS Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.