javascript - Angular 5 延迟加载不起作用。共享模块不工作
问题描述
我们正在尝试在我们的项目中实现延迟加载。但我有一个奇怪的错误。基本上,我为组件创建了一个模块,并在 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 { }
共享模块.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 { }
解决方案
推荐阅读
- azure-logic-apps - Microsoft Logic App 和 Workflow 是否相同
- html - div内的CSS定位范围
- spring-boot - 为什么spring data jpa不需要@Repository?
- reactjs - 从 API 获取数据后如何设置 react-select 的默认值
- azure - Azure AD B2C - 如何查看用户的扩展
- r - 如果一行包含一个值,如何删除列?
- javascript - 工作箱 registerRoute 不适用于特殊路线
- groovy - NEXUS神器下载解压
- c# - 如何在 Dotnet 中上传图像?
- python - 带条件的 MultiIndex 数据帧的操作