O'Reilly logo

AngularJS Directives by Alex Vanston

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

ng-repeat

To start our study into the primary use cases for the compile function, let's take a look at the definition object for the built-in directive ng-repeat. The definition object is as follows:

...
.directive('ngRepeat', function () {
  return {
    priority: 1000,
    transclude: 'element',
    terminal: true,
    compile: function(element, attr, linker) { // Compile Function
      return function(scope, iterStartElement, attr){ // Linking Function
      };
    }
  }
});

The first few properties should be familiar from the previous chapter, but let's quickly review how each is used here. A priority value of 1000 makes sure that this directive executes before any others on the element, and setting terminal to true ensures that Angular's automatic compilation doesn't continue ...

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