di provider angular code example
Example 1: how to inject service in component angular 6
you can inject service in components constructor:
constructor(public anyService: Service){}
Example 2: injection of generic services in angular
@NgModule({
imports: [CommonModule],
declarations: [Component3Component],
exports: [Component3Component],
providers: [ApiService, { provide: MY_API_ENDPOINT, useValue: "api.end.point.3" }]
})
export class App2Module { }