AngularJS Essentials
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Creating Reusable Components with Directives<br />
<br />
<br />
Blue - 10/10/2002 11:10<br />
<br />
directives.html<br />
parking.directive("accordionItem", function () {<br />
return {<br />
templateUrl: "accordionItem.html",<br />
restrict: "E",<br />
scope: {<br />
title: "@"<br />
},<br />
transclude: true,<br />
link: function (scope, element, attrs, ctrl, transcludeFn) {<br />
element.bind("click", function () {<br />
scope.$apply(function () {<br />
scope.active = !scope.active;<br />
});<br />
});<br />
}<br />
};<br />
});<br />
accordionItem.html<br />
<br />
{{title}}<br />
<br />
<br />
<br />
require<br />
The require property is used to inject another directive controller as the fourth<br />
parameter of the link function. It means that using this property, we are able to<br />
communicate with the other directives. Some of the parameters are shown in the<br />
following table:<br />
[ 44 ]<br />
www.it-ebooks.info