我有一个名为的库foo,其中包含一个名为的角度组件FooContentComponent,它呈现各种类型的内容:
<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>
FooContentComponent有自己的ngModule。同样的FooMathComponent也住在自己的ngModule。
这是问题所在:我不想在FooMathModule. FooContentModule相反,我想将它留给使用foo库的应用程序来包含FooMathModule如果应用程序想要呈现数学内容。如果应用程序不想呈现数学内容,它将不会FooMathModule在其应用程序模块中导入。
如果我不导入FooMathModule内部,FooContentModule我会从编译器那里得到一个它不知道的错误foo-math。我可以通过在 中指定自定义模式来消除错误FooContentModule,但它仍然不会呈现FooMathComponent.
我可以这样做吗?