Dependency Injection with AngularJS

If you want to start using AngularJS for real, this is the book you need. Its down-to-earth practical approach will quickly teach you all you need to know about dependency injection utilizing this versatile framework.

Dependency Injection with AngularJS

Progressing
Alex Knol

If you want to start using AngularJS for real, this is the book you need. Its down-to-earth practical approach will quickly teach you all you need to know about dependency injection utilizing this versatile framework.
$17.99
$29.99
RRP $17.99
RRP $29.99
eBook
Print + eBook
$12.99 p/month

Want this title & more? Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.
Code Files
+ Collection
Free Sample

Book Details

ISBN 139781782166566
Paperback78 pages

About This Book

  • Understand the concept of dependency injection
  • Isolate units of code during testing JavaScript using Jasmine
  • Create reusable components in AngularJS

Who This Book Is For

Dependency Injection with AngularJS is aimed at developers who are aware of AngularJS but need to get started with using it in real life applications. Also, developers who want to get into test-driven development with AngularJS can use this book as practical guide. Even if you know about dependency injection, it can serve as a good reference on how it is used within AngularJS. Readers are expected to have some experience with JavaScript.

Table of Contents

Chapter 1: Learning to Fly
Let's get going
Adding a controller
What about routes?
Showing a list
Adding a filter
Chart directives
Summary
Chapter 2: Better Code
Wiring up the backend
Duplicating code
Angular service to the rescue
The theory behind Dependency Injection
Summary
Chapter 3: The Magic
Application flow
Different ways of injecting
Summary
Chapter 4: Testing
Test automation
Test your code, not the framework
Testing the parts
The Karma test runner
End-to-end testing
Summary
Chapter 5: Large Applications
Organizing your application
Organizing using dynamic teams
Nesting controllers
More powerful nesting
Application communication
Summary

What You Will Learn

  • Create reusable components propelled by the independence of components from each other
  • Run tests on real browsers using the Karma test runner
  • Set up Jasmine BDD testing
  • Set up and install AngularJS
  • Change coupled code to loosely coupled injected dependencies
  • Create integration tests using Protractor
  • Organize large applications using dependency injection

In Detail

Dependency injection facilitates better testing by allowing us to mock dependencies in testing environments so that we only test one thing at a time. It also enables us to write more maintainable code by decoupling our objects from their implementations. The motivation for using it in AngularJS is to make it easier to transparently load mocked objects in tests.

This book is a practical manual to get you started on dependency injection. It will also take you along the road to creating testable and reusable code. Ensuring productivity and stability are the two most important things that you will learn.

"Dependency Injection with AngularJS" will introduce you to AngularJS using a simple sample project. By portraying different ways of developing code modules, it will show you the advantages of dependency injection. This will lead to the ability to create reusable components that can easily be tested.

The book contains a section that will show you how to make a chart component to display historical data. A short chapter will explain some of the theory and the reasons behind dependency injection. You will be introduced to Jasmine, a JavaScript behavior-driven development testing framework. You will learn how to test your code in real browsers using Karma, the lightning fast AngularJS test runner. Lastly the book will show you how to build reusable components you can stack on top of each other.

You will learn everything you need to know how to use dependency injection with AngularJS.

Authors

Table of Contents

Chapter 1: Learning to Fly
Let's get going
Adding a controller
What about routes?
Showing a list
Adding a filter
Chart directives
Summary
Chapter 2: Better Code
Wiring up the backend
Duplicating code
Angular service to the rescue
The theory behind Dependency Injection
Summary
Chapter 3: The Magic
Application flow
Different ways of injecting
Summary
Chapter 4: Testing
Test automation
Test your code, not the framework
Testing the parts
The Karma test runner
End-to-end testing
Summary
Chapter 5: Large Applications
Organizing your application
Organizing using dynamic teams
Nesting controllers
More powerful nesting
Application communication
Summary

Book Details

ISBN 139781782166566
Paperback78 pages
Read More