In Angular dependency, injection is used to inject the dependencies of services. A Provider works as an instructor for the dependency injection system to resolve the dependencies. When you create any service, it comes with default @Injectable decorator that contains a default property 'providedIn,' which establishes the provider for service.



  providedIn: 'root',
export class DataService {

You can inject the services in the root or particular module as well, and you can limit the scope of service to a particular component by using component providers.

  providers: [DataService]


Suggest An Answer

No suggestions Available!