我们正在尝试在我们的项目中实现延迟加载。但我有一个奇怪的错误。基本上,我为一个组件创建了一个模块,并在 app.module 中使用了 loadchildren。但是在 Html 中,该组件中还使用了另一个组件,就像这样
<cr-configure-button></cr-configure-button>
所以对于这个组件,我收到这个错误
Can't bind to 'hub' since it isn't a known property of 'cr-configure-button'.
1. If 'cr-configure-button' is an Angular component and it has 'hub' input, then verify that it is part of this module.
2. If 'cr-configure-button' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component
对于这个组件,我创建了一个导出这个组件的共享模块。请看下面的代码
请帮忙。
提前致谢
app.module.ts
{ path: 'modules', loadChildren: './hubs/hubs.module#HubsModule' },
hubs.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HubsRoutingModule } from './hubs-routing.module';
import { HubsComponent } from './hubs.component';
import { SharedModule } from '@shared/shared.module';
@NgModule({
imports: [
CommonModule,
HubsRoutingModule,
SharedModule,
],
declarations: [
HubsComponent,
],
})
export class HubsModule { }
shared.moudule.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CrConfigureButtonComponent } from './components/buttons/cr-configure-button';
@NgModule({
imports: [
CommonModule,
],
declarations: [CrConfigureButtonComponent],
exports: [CrConfigureButtonComponent],
})
export class SharedModule { }