2017-12-02 22 views
2

這是我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; –

回答

0

謝謝大家。 它重新編譯代碼後工作。

相關問題