30 seconds of angular
Star
✨✨ New to Angular? Check out interactive Angular Codelab ✨✨

Component level providers

Generally we get one service instance per the whole application.
It is also possible to create an instance of service per component or directive.

@Component({
  selector: 'provide',
  template: '<ng-content></ng-content>',
  providers: [ Service ]
})
export class ProvideComponent {}
@Directive({
  selector: '[provide]',
  providers: [ Service ]
})
export class ProvideDirective {}

Links

Interactive demo