Understanding Custom Directive Definitions

You implement custom directives by calling the directive() method on a Module object. The directive() method accepts the name of a directive as the first parameter and a provider function that returns an object containing the necessary instructions to build the directive object. For example, the following is a basic definition for a directive:

angular.module('myApp', []).
  directive('myDirective', function() {
    return {
      template: 'Name: {{name}} Score: {{score}}'
    };
  });

Table 7.1 provides a list of the properties you can apply to the object returned by the directive definition as template is returned in the preceding code.

Image
Image

Table 7.1 Directive Definition Properties That Define AngularJS Directive Functionality

The following sections discuss the directive options in more detail.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset