简体   繁体   中英

Can't bind to 'property' since it isn't a known property of 'cmp'

I have following components and modules:

ChartComponent

@Component({
          moduleId: module.id,
          selector: 'chart-cmp',
            template: ''
        })
export class ChartComponent implements OnChanges {
    @Input
    typeId : string;

    @Input
    username : string;

    @Input
    grain : string;
...}

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

import { Component, Input } from '@angular/core';

@Component({
  moduleId: module.id,
  selector: 'chart-panel-cmp',
    templateUrl: 'chart_panel.component.html'
})
export class ChartPanelComponent {

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

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

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'. 1. If 'chart-cmp' is an Angular component and it has 'typeId' input, then verify that it is part of this module. 2. If 'chart-cmp' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message.

You need to add () to your @Input decorators:

@Input()
typeId : string;

@Input()
username : string;

@Input()
grain : string;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM