O'Reilly logo

AngularJS Essentials by Rodrigo Branas

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.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required