Angular & Signals (283 Qs)•Part 9: NgModules, Providers, NgZone & Injector Hierarchies (213 - 255)
What is a provider?
A provider is an instruction to the Dependency Injection system on how to obtain a value for a dependency(aka services created). The service can be provided using Angular CLI as below,
javascript
ng generate service my-service
The created service by CLI would be as below,
js
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root', //Angular provide the service in root injector
})
export class MyService {
}