Why to use private access specifier only to instantiate the providers in constructor ? Is there any specific reason to use private access specifiers only ?
Private injection
constructor(private service: InjectedService)
Public injection
constructor(service: InjectedService)
Using private acts a shorthand, instead of doing:
constructor(service: InjectedService) {
this.service = service
}
you can:
constructor(private service: InjectedService) {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With