[英]Can't bind to 'property' since it isn't a known property of 'cmp'
I have following components and modules: 我有以下组件和模块:
ChartComponent ChartComponent
@Component({
moduleId: module.id,
selector: 'chart-cmp',
template: ''
})
export class ChartComponent implements OnChanges {
@Input
typeId : string;
@Input
username : string;
@Input
grain : string;
...}
ChartModule ChartModule
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChartComponent } from './chart.component';
@NgModule({
imports: [RouterModule],
declarations: [ChartComponent],
exports: [ChartComponent]
})
export class ChartModule { }
ChartPanelComponent ChartPanelComponent
import { Component, Input } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'chart-panel-cmp',
templateUrl: 'chart_panel.component.html'
})
export class ChartPanelComponent {
ChartPanelModule ChartPanelModule
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChartPanelComponent } from './chart_panel.component';
import { ChartModule } from '../chart/chart.module';
@NgModule({
imports: [RouterModule, ChartModule],
declarations: [ChartPanelComponent],
exports: [ChartPanelComponent]
})
export class ChartPanelModule { }
ConsoComponent ConsoComponent
import { Component, OnInit, ElementRef, Inject, forwardRef } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { DashboardComponent } from '../dashboard.component';
@Component({
moduleId: module.id,
selector: 'conso-cmp',
templateUrl: 'conso.component.html'
})
export class ConsoComponent implements OnInit {...}
ConsoModule ConsoModule
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ConsoComponent } from './conso.component';
import { ChartPanelModule } from '../chart_panel/chart_panel.module';
@NgModule({
imports: [RouterModule, ChartPanelModule],
declarations: [ConsoComponent],
exports: [ConsoComponent]
})
export class ConsoModule { }
I get the following error: 我收到以下错误:
Unhandled Promise rejection: Template parse errors: Can't bind to 'typeId' since it isn't a known property of 'chart-cmp'. 未处理的Promise拒绝:模板解析错误:无法绑定到'typeId',因为它不是'chart-cmp'的已知属性。 1. If 'chart-cmp' is an Angular component and it has 'typeId' input, then verify that it is part of this module. 1.如果'chart-cmp'是一个Angular组件并且它有'typeId'输入,那么请验证它是否是该模块的一部分。 2. If 'chart-cmp' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. 2.如果'chart-cmp'是Web组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到此组件的'@NgModule.schema'以禁止显示此消息。
You need to add ()
to your @Input
decorators: 你需要添加()
到你的@Input
装饰器:
@Input()
typeId : string;
@Input()
username : string;
@Input()
grain : string;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.