角4无法绑定到“childinfor”,因为它不是“应用程序属性瓷砖”的已知财产

问题描述:

这是我app.componemt.html文件代码角4无法绑定到“childinfor”,因为它不是“应用程序属性瓷砖”的已知财产

<ng-container *ngFor="let contact of data.featured_property" > 
     <app-property-tile [childinfor]="contact"></app-property-tile> 
    </ng-container> 

这是我的财产-tile.component.html文件代码

<h5 class="full_width">{{childinfor.name}}</h5> 

这是我的财产,tile.component.ts文件代码

import { Component, OnInit, Input } from '@angular/core'; 
@Component({ 
selector: 'app-property-tile', 
    templateUrl: './property-tile.component.html', 
    styleUrls: ['./property-tile.component.scss'] 
}) 
export class PropertyTileComponent implements OnInit { 
    @Input() childinfor: object; 
    constructor() { } 

    ngOnInit() { 
    } 

} 

这是API JSON对象。

{"featured_property":[{"id":1,"name":"abc"},{"id":2,"name":"pqr"}]} 

我不能发现其中的错误。请帮我解决这个问题。

+0

这很奇怪,尝试用'ng build'或'ng serve'重新编译项目。 –

+0

如果不是,请在AppModule声明数组中添加'PropertyTileComponent'。 –

+0

尝试@Input()childinfor:any; –

添加CommonModulePropertyTileComponent声明的NgModule
你可以找到更多关于此话题https://angular.io/guide/ngmodule-faq#what-should-i-import

谢谢大家。 它重新编译代码后工作。