I am building a application and part of the code allows developer to specify which component they want to render a certain part. I want users to know they need to implement an interface but I am not sure how to write typing correctly.
export interface ICustomComponent {
templateObject: any;
}
export class MyComponent implements ICustomComponent {
}
export class MyLib {
constructor(
private yourComponent: ICustomComponent
) {}
}
new MyLib(MyComponent); <== Fails
I am writing code with Angular, and I cannot run new operator but let Angular to resolve and construct that component.
Here an example that illustrates my problem.
How to deal with this problem?
new MyLib(...);? Instance likenew MyLib(new MyComponent());or reference to the class?MyComponentto componentFactoryResolver.resolveComponentFactory(MyComponent);`?