這是我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"}]}
我不能發現其中的錯誤。請幫我解決這個問題。
這很奇怪,嘗試用'ng build'或'ng serve'重新編譯項目。 –
如果不是,請在AppModule聲明數組中添加'PropertyTileComponent'。 –
嘗試@Input()childinfor:any; –