Reputation: 2654
Not sure what is the best option but here it goes.
I have the following class
export class Order {
number?: any;
api?: ApiRequest;
constructor(number, api: ApiRequest) {
this.number = number;
this.api = api;
}
}
When i create the order i use the following
let order new Order(123, this.request);
ApiRequest is an injectable global provider.
Is there a way i can automatically inject the api provider in the class when i create a new object?
Upvotes: 1
Views: 547
Reputation: 657158
No. Injecting only works for instances that are created by DI, not if you create one yourself with new Xxx()
.
Upvotes: 1