它在 Angular 7 中工作,现在更新后会抛出未知元素错误。这种情况发生在共享模块中。
可复现的代码:- https://stackblitz.com/edit/angular-ivy-pb3eea 我有一个父组件 'Parent',在其中使用子组件 'Child',并在父组件和子组件中都使用共享组件 'Shared'。
因此,我已经在父组件和子组件的两个模块中都导入了共享组件。(因为使用了懒加载模块)在父组件中它可以工作,但在子组件中却不行。
可复现的代码:- https://stackblitz.com/edit/angular-ivy-pb3eea 我有一个父组件 'Parent',在其中使用子组件 'Child',并在父组件和子组件中都使用共享组件 'Shared'。
因此,我已经在父组件和子组件的两个模块中都导入了共享组件。(因为使用了懒加载模块)在父组件中它可以工作,但在子组件中却不行。
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TestChildRoutingModule} from './test-child.routing.module';
import { SharedModule } from '../shared/shared.module';
@NgModule({
declarations: [
],
imports: [
CommonModule,
SharedModule,
TestChildRoutingModule
],
exports: [
]
})
export class TestChildModule { }