https://angular.io/guide/dependency-injection#injectable-ngmodule-or-component
$ng generate service heroes/hero
import { Injectable } from '@angular/core';
@Injectable({
// we declare that this service should be created
// by the root application injector.
providedIn: 'root',
})
@Injectable({
// we declare that this service should be created
// by any injector that includes HeroModule.
providedIn: HeroModule,
})
@Component({
selector: 'app-unsorted-heroes',
template: `<div *ngFor="let hero of heroes">{{hero.name}}</div>`,
providers: [HeroService]
})
export class HeroesBaseComponent implements OnInit {
constructor(private heroService: HeroService) { }
}
{ provide: MyService, useClass: MyMockService }
{ provide: MyService, useFactory: myFactory }
{ provide: MyValue, useValue: 41 }