Dependency Injection with AngularJS
- Length: 78 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2013-12-18
- ISBN-10: 1782166564
- ISBN-13: 9781782166566
- Sales Rank: #7819741 (See Top 100 Books)
Design, control, and manage your dependencies with AngularJS dependency injection
Overview
- Understand the concept of dependency injection
- Isolate units of code during testing JavaScript using Jasmine
- Create reusable components in AngularJS
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.
You will learn everything you need to know how to use dependency injection with AngularJS.
What you will learn from this book
- 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
Approach
This book is a practical, hands-on approach to using dependency injection and implementing test-driven development using AngularJS.
Who this book is written 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
Chapter 2: Better Code
Chapter 3: The Magic
Chapter 4: Testing
Chapter 5: Large Applications