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

The initial directive

Now that we have our first couple tests ready and running, let's move forward with the directive code. I won't include every line of the directive here, just the key pieces for the sake of space. To review all the code, run git checkout initialTests within your cloned repository directory. Now, without further ado, the directive is:

angular.module('mvdContentGrid', ['ngSanitize']) .directive('contentGrid', function () { return { template : /* … */, replace : true, scope : { 'elements' : '=contentGrid' } } }) .directive('contentGridElement', function () { return { template : /* … */, replace : true, scope : { 'contentElement' : '=contentGridElement' }, link : function ($scope, $element, $attrs) { $element.data('element-id', ...

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