导入,变量声明完成。仍然抛出错误。另请阅读有关 SO 的旧问题。
app.module.ts:
import { HotelTableComponent } from './hotel-table/hotel-table.component';
import { HotelTableRowComponent } from './hotel-table-row/hotel-table-row.component';
@NgModule({
declarations: [
AppComponent,
HotelTableComponent,
HotelTableRowComponent
],
酒店表行.component.ts:
@Component({
selector: 'app-hotel-table-row',
.....
export class HotelTableRowComponent implements OnInit {
@Input() character: any;
@Input() columns: string[];
酒店-table.component.html:
<table>
<tr>
<th *ngFor="let c of columns">{{c}}</th>
</tr>
<tr *ngFor="let ch of characters | async"
app-hotel-table-row
[character]="ch"
[columns]="columns">
</tr>
</table>
安慰:
compiler.js:215 Uncaught Error: Template parse errors:
Can't bind to 'character' since it isn't a known property of 'tr'. ("
<tr *ngFor="let ch of characters | async"
app-hotel-table-row
[ERROR ->][character]="ch"
[columns]="columns">
</tr>
"): ng:///AppModule/HotelTableComponent.html@7:4
Can't bind to 'columns' since it isn't a known property of 'tr'. ("
app-hotel-table-row
[character]="ch"
[ERROR ->][columns]="columns">
</tr>
"): ng:///AppModule/HotelTableComponent.html@8:4