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.

Creating Reusable Components with Directives<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Park<br />

<br />

<br />

<br />

The ngOptions directive<br />

The ngRepeat directive can be used to create the options of a select element;<br />

however, there is a much more recommended directive that should be used for<br />

this purpose—the ngOptions directive.<br />

Through an expression, we need to indicate the property of the scope from which the<br />

directive will iterate, the name of the temporary variable that will hold the content of<br />

each loop's iteration, and the property of the variable that should be displayed.<br />

In the following example, we have introduced a list of colors:<br />

index.html<br />

<br />

<br />

<br />

[Packt] Parking<br />

<br />

[ 28 ]<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!