我有以下组件和模块:
ChartComponent
False
ChartModule
@Component({
moduleId: module.id,
selector: 'chart-cmp',
template: ''
})
export class ChartComponent implements OnChanges {
@Input
typeId : string;
@Input
username : string;
@Input
grain : string;
...}
ChartPanelComponent
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 { }
ChartPanelModule
import { Component, Input } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'chart-panel-cmp',
templateUrl: 'chart_panel.component.html'
})
export class ChartPanelComponent {
ConsoComponent
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 { }
ConsoModule
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 {...}
我收到以下错误:
未处理的承诺拒绝:模板解析错误: 无法绑定到' typeId'因为它不是&chart; cmp'的已知属性。 1.如果' chart-cmp'是一个Angular组件,它有' typeId'输入,然后验证它是否是该模块的一部分。 2.如果' chart-cmp'是一个Web组件,然后添加" CUSTOM_ELEMENTS_SCHEMA"到' @ NgModule.schema'该组件可以禁止此消息。
答案 0 :(得分:3)
您需要将()
添加到@Input
装饰器:
@Input()
typeId : string;
@Input()
username : string;
@Input()
grain : string;