I have a service that requires some value to be initiated:
@Injectable()
export class MyService {
private myVals: any;
constructor(init : any) {
this.myVals = init;
}
}
And the consumer:
@Component(...)
export class MyComponent {
private svc: MyService;
constructor(private svc : MyService) {
}
}
So is there a way to inject and pass the required parameter to MyService
's constructor
"during" dependency injection??
Something like:
constructor(private svc({ // init vales }) : MyService) {}
I know I can pass by variable, but interested to find if there's a way to do this from the API.