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.
Getting Started with <strong>AngularJS</strong><br />
<br />
<br />
<br />
<br />
<br />
{{car.plate}}<br />
<br />
<br />
<br />
<br />
<br />
<br />
Park<br />
<br />
<br />
Apart from learning how to set up the framework in this section, we also introduced<br />
some directives that we are going to study in the Chapter 2, Creating Reusable<br />
Components with Directives.<br />
The ngController directive is used to bind the parkingCtrl controller to the view,<br />
whereas the ngRepeat directive iterates over the car's array. Also, we employed<br />
expressions such as {{car.plate}} to display the plate of the car. Finally, to add<br />
new cars, we applied the ngModel directive, which creates a new object called car<br />
with the plate property, passing it as a parameter of the park function, called<br />
through the ngClick directive.<br />
To improve the loading page's performance, you are recommended to use the<br />
minified and obfuscated version of the script that can be identified by angular.min.<br />
js. Both minified and regular distributions of the framework can be found on the<br />
official site of <strong>AngularJS</strong> (http://www.angularjs.org) or in the Google Content<br />
Delivery Network (CDN).<br />
Organizing the code<br />
As soon as we start coding our views, controllers, services, and other pieces of<br />
the application, as it used to happen in the past with many other languages and<br />
frameworks, one question will certainly come up: "how do we organize the code?"<br />
Most software developers struggle to decide on a lot of factors. This includes figuring<br />
out which is the best approach to follow (not only regarding the directory layout, but<br />
also about the file in which each script should be placed), whether it is a good idea to<br />
break up the application into separated modules, and so on.<br />
[ 12 ]<br />
www.it-ebooks.info