角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"}]}
我不能发现其中的错误。请帮我解决这个问题。
回答:
添加CommonModule
到PropertyTileComponent
声明的NgModule
你可以找到更多关于此话题https://angular.io/guide/ngmodule-faq#what-should-i-import
回答:
谢谢大家。 它重新编译代码后工作。
以上是 角4无法绑定到“childinfor”,因为它不是“应用程序属性瓷砖”的已知财产 的全部内容, 来源链接: utcz.com/qa/258227.html