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.

Table of Contents<br />

Chapter 4: Dependency Injection and Services 67<br />

Dependency injection 68<br />

Creating services 69<br />

Creating services with the factory 70<br />

Creating services with the service 74<br />

Creating services with the provider 75<br />

Using <strong>AngularJS</strong> built-in services 76<br />

Communicating with the backend 76<br />

HTTP, REST, and JSON 76<br />

Creating an HTTP facade 82<br />

Headers 84<br />

Caching 85<br />

Interceptors 85<br />

Creating a single-page application 87<br />

Installing the module 87<br />

Configuring the routes 87<br />

Rendering the content of each view 88<br />

Passing parameters 91<br />

Changing the location 92<br />

Resolving promises 93<br />

Logging 96<br />

Timeout 96<br />

Asynchronous with a promise-deferred pattern 98<br />

The deferred API 100<br />

The promise API 101<br />

Summary 101<br />

Chapter 5: Scope 103<br />

Two-way data binding 103<br />

$apply and $watch 104<br />

Best practices using the scope 106<br />

The $rootScope object 110<br />

Scope Broadcasting 110<br />

Summary 113<br />

Chapter 6: Modules 115<br />

Creating modules 115<br />

The UI module 116<br />

The search module 118<br />

The parking application module 119<br />

Recommended modules 120<br />

Summary 120<br />

[ iii ]<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!