Understanding Dependency Injections in Angular

What is Dependency Injections

A dictionary definition of Dependency Injection would be something like:

Ways of using a service for data sharing.

  1. Create a new instance of service class every time it is used
(Source: Deborah Kurata, 2018)

How does Angular Dependency Injection work?

When an Injector annotation is specified for a service class, the specified instance is stored in Angular’s inbuilt Injector. Angular’s Injector is a container which creates and manages single instance(Singleton) of each registered service.

import { Injectable } from ‘@angular/core’;@Injectable()
export class myService {}
(Source: Deborah Kurata, 2018)

Further References

Senior Software Engineer at 99x | Freelance developer | Interested in History and Philosophy

Senior Software Engineer at 99x | Freelance developer | Interested in History and Philosophy