相关疑难解决方法(0)

许多使用相同组件的模块会导致错误 - Angular 2

我有一个名为GoComponent的共享组件,我想在2个模块中使用:FindPageModule和AddPageModule.

当我在"FindPageModule"的声明和我的"AddPageModule"中添加它时,我收到一个错误:

find:21错误:(SystemJS)类型GoComponent是2个模块的声明的一部分:FindPageModule和AddPageModule!请考虑将GoComponent移动到导入FindPageModule和AddPageModule的更高模块.您还可以创建一个新的NgModule,它导出并包含GoComponent,然后在FindPageModule和AddPageModule中导入该NgModule.

所以我把它们从它们中取出并将它添加到AppModule声明中,它确实导入了FindPageModule和AddPageModule,并且在FindPageModule声明中使用"GoComponent"的组件中出现了一个名为"FindFormComponent"的组件中的错误:

zone.js:355 Unhandled Promise rejection: Template parse errors:
'go' is not a known element:
1. If 'go' is an Angular component, then verify that it is part of this module.
2. If 'go' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. (" style="height:64px;">
            <div style="position: relative; display: inline-block; width: 100%;">
                [ERROR ->]<go></go>
            </div>
        </div>
"): FindFormComponent@101:4 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:(…) …
Run Code Online (Sandbox Code Playgroud)

ng-modules angular

18
推荐指数
1
解决办法
2万
查看次数

标签 统计

angular ×1

ng-modules ×1