Can we inject different provider while loading components dynamically?
my-component
@Component({
moduleId: module.id,
selector: "my-component",
template: "<div>my-component</div>",
providers: [MyComponentService]
})
export class MyComponent{
constructor(private ds: MyComponentService) {
super();
}
}
some where else,
this._cr.resolveComponent(MyComponent).then(cmpFactory => {
let instance: any = this.testComponentContainer.createComponent(cmpFactory).instance;
});
so in above code, while resolving MyComponent
, provider for this MyComponentService
will also be resolved, can we resolve it differently based upon some switch?