Book Image

AngularJS Essentials

By : Rodrigo Branas
Book Image

AngularJS Essentials

By: Rodrigo Branas

Overview of this book

<p>This book is a practical guide filled with real-world examples that will help you discover the best practices of the AngularJS framework, covering its most important concepts such as directives, expressions, filters, and modules and guiding you through the steps of building your very own web application.</p> <p>You will start by learning how to create reusable components with directives, experiencing an expressive way of developing software. Then we will move on to cover data handling, and you will learn how to use the various features of the AngularJS framework to accomplish any challenge related to presenting, transforming, and validating data on a user's interface.</p> <p>After that, we will explore the secrets of the dependency injection mechanism available in AngularJS, bringing reuse and testability to your application by decoupling the layers. The book will also cover the best practices of using the framework and how to automate the test and the project's workflow.</p>
Table of Contents (16 chapters)

Best practices using the scope


The scope is not the model itself—it's just a way to reach it. Thus, the view and controller layers are absolutely free to share any kind of information, even those that are not related to the model, and they only exist to fulfill specific layout matters such as showing or hiding a field under a determined condition.

Be careful about falling into a design trap! The freedom provided by the scope can lead you to use it in a wrong way. Keep the following advice in mind:

"Treat scope as read-only inside the view and write-only inside the controller as possible."

Also, we will go through some important advice about using the scope:

Avoid making changes to the scope directly from the view

This means that though it is easy, we should avoid making changes to the scope by creating or modifying its properties directly inside the view. At the same time, we need to take care about reading the scope directly everywhere inside the controller.

The following is an example from...