简体   繁体   English

无法绑定到'property',因为它不是'cmp'的已知属性

[英]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.

相关问题 角度-无法绑定到“属性”,因为它不是“ a”的已知属性 - Angular - Can't bind to 'property' since it isn't a known property of 'a' 无法绑定到“属性”,因为它不是“组件”的已知属性 - Can't bind to 'property' since it isn't a known property of 'component' 无法绑定到属性,因为它不是组件的已知属性 - Can't bind to property since it isn't a known property of a component 无法绑定到属性,因为它不是元素的已知属性 - Can't bind to property since it isn't a known property of element 无法绑定到“上载器”,因为它不是“ div”的已知属性 - Can't bind to 'uploader' since it isn't a known property of 'div' 无法绑定到“ ngModel”,因为它不是“ select”的已知属性 - Can't bind to 'ngModel' since it isn't a known property of 'select' 无法绑定到“图形”,因为它不是“画布”的已知属性 - Can't bind to 'graph' since it isn't a known property of 'canvas' 无法绑定,因为它不是选择器组件的已知属性 - Can't bind to since it isn't a known property of selector component 无法绑定到“ngForOf”,因为它不是组件的已知属性 - Can't bind to 'ngForOf' since it isn't a known property of component 无法绑定到“shouldLabelFloat”,因为它不是“input”的已知属性 - Can't bind to 'shouldLabelFloat' since it isn't a known property of 'input'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM