0
经过本页面的长时间搜索后,我仍然丢失。CustomModule的组件忽略AppModule中的顶层声明
我有一个AppModule和一个ModalModule。的AppModule是进口ModalModule
的AppModule声明LoaderComponent与这个装饰属性:
selector: 'my-loader', template: '<div>...</div><ng-content></ng-content>'
ModalModule声明ModalComponent。
我想用LoaderComponent ModalComponent的模板中:
<my-loader><h3>Loading...</h3><p>Just information text.</p></my-loader>
而且这也不行!
'my-loader' is not a known element:
1. If 'my-loader' is an Angular component, then verify that it is part of this module.
2. If 'my-loader' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
如果我添加CUSTOM_ELEMENTS_SCHEMA到ModalModule,它只是忽略元素和DOM看起来是这样的:
<my-loader>
<h3>Loading...</h3>
<p>Just information text.</p>
</my-loader>
但我希望它通过角度呈现,看起来就像这样:
<my-loader>
<div>...</div> <!-- should be coming from LoaderComponent template -->
<h3>Loading...</h3>
<p>Just information text.</p>
</my-loader>
有人有想法吗?
在我的文章后,我发现这一点,并会尝试它:https://stackoverflow.com/questions/39906949/angular2-how-to-clean-up-the-appmodule/39907757#39907757 –