O'Reilly logo

Learning Angular for .NET Developers by Rajesh Gunasundaram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling dependency injection in Angular

Angular has its own dependency injection framework, and we will see, with an example, how it handles dependency injection.

First, we will create a Todo class under app/todos/todo.ts with properties such as id, description, and isCompleted, as given in the following screenshot:

A code snippet of the Todo class

Then, create a TodoListComponent component and add the property to hold the collection of todo items retrieved from the injected TodoService. The service will be injected into constructor when TodoListComponent is instantiated by the dependency injection framework. You will learn more about services ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required