Switch to the store?

Dependency Injection with AngularJS

More Information
  • 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

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.

  • Understand the concept of dependency injection
  • Isolate units of code during testing JavaScript using Jasmine
  • Create reusable components in AngularJS
Page Count 78
Course Length 2 hours 20 minutes
ISBN 9781782166566
Date Of Publication 18 Dec 2013


Alex Knol

Alex Knol is a lifelong tech geek with a passion for automation. After spending some years away from software development, around the beginning of this century, he took up PHP development based on his early experiences with C and Pascal. Surprisingly, he has never really used web tools, but applications instead, to make websites, such as the platform that's driving kaizegine.com. Having built various applications using web technologies and frameworks, such as Symfony, he discovered AngularJS at the beginning of 2008, while searching for a way to structure frontend application code and make development easy. He used AngularJS, among other technologies, for a job-matching project in the Netherlands and, more recently, for an online website designer named Risingtool.com.