FrontendDeveloper.in

Angular question detail

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,

ng generate service my-service

The created service by CLI would be as below,

import { Injectable } from '@angular/core';

@Injectable({
providedIn: 'root', //Angular provide the service in root injector
})
export class MyService {
}
Back to all Angular questions
Get LinkedIn Premium at Rs 399