16.07.2017 Views

AngularJS Essentials

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 2<br />

Prefix<br />

(no<br />

prefix)<br />

Details<br />

This parameter locates the controller inside the current element. It throws<br />

an error if the controller is not defined within the require directive.<br />

? This parameter tries to locate the controller, passing null to the controller<br />

parameter of the link function if not found.<br />

^<br />

This parameter locates the controller in the parent element. It throws an<br />

error if the controller is not defined within any parent element.<br />

?^ This parameter tries to locate the controller in the parent element, passing<br />

null to the controller parameter of the link function if not found.<br />

In our last example, each accordion is independent. We can open and close all of<br />

them at our will. This property might be used to create an algorithm that closes all<br />

the other accordions as soon as we click on each of them:<br />

index.html<br />

<br />

<br />

White - 10/10/2002 10:00<br />

<br />

<br />

Black - 10/10/2002 10:36<br />

<br />

<br />

Blue - 10/10/2002 11:10<br />

<br />

<br />

directives.html<br />

parking.directive("accordion", function () {<br />

return {<br />

template: "",<br />

restrict: "E",<br />

transclude: true<br />

};<br />

});<br />

parking.directive("accordionItem", function () {<br />

return {<br />

templateUrl: "accordionItem.html",<br />

restrict: "E",<br />

scope: {<br />

[ 45 ]<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!