I have a library called foo
that contains an angular component called FooContentComponent
that renders various types of content:
<ng-container *ngFor="let item of contents">
<ng-container *ngIf="item.type === 'text'">{{item.text}}</ng-container>
<ng-container *ngIf="item.type === 'math'">
<foo-math [formula]="item.formula"></foo-math>
</ng-continer>
</ng-container>
The FooContentComponent
has its own ngModule
. Similarly the FooMathComponent
also lives in its own ngModule
.
Here's the problem: i don't want to explicitly import the FooMathModule
in the FooContentModule
. Instead i want to leave it up to the application using the foo
library to include the FooMathModule
if the application wants to render math content. If the application doesn't want to render math content, it will not import the FooMathModule
in its app module.
If i don't import the FooMathModule
inside FooContentModule
i will get an error from the compiler that it doesn't know foo-math
. I can get rid of the error by specifying a custom schema in the FooContentModule
, but then it still won't render the FooMathComponent
.
Can i do this?