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.

Modules<br />

As our application grows, we need to consider the possibility of splitting it into<br />

different modules. It comes with it a lot of advantages, thus helping us to find the<br />

best way to test and evolve each module separately from the others and also to share<br />

each module with other projects.<br />

In this chapter, we are going to cover the following topics:<br />

• How to create modules<br />

• Recommended modules<br />

Creating modules<br />

By gaining an in-depth understanding of the underlying business inside our<br />

application, we can isolate each group of functionalities (which are correlated) into<br />

a separated module. In the case of our parking application, we can split it into three<br />

different modules:<br />

• UI: This module gives directives that could be used by other projects such as<br />

alert, accordion, modal, tab, and tooltip.<br />

• Search: The search engine we created to filter cars could also be separated as<br />

an individual library and reused in other places.<br />

• Parking: This is the parking application itself, with its own resources such as<br />

views, controllers, directives, filters, and services.<br />

First, we need to create each new module separately and then they need to be<br />

declared inside the parking application module such that they are available.<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!