代码:
<div class="news" *ngFor="let post of list">
<mat-accordion class="accordion">
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title >{{post.title}}</mat-panel-title>
<div class="w3-right">
<mat-panel-title >{{post.date}}</mat-panel-title>
</div>
</mat-expansion-panel-header>
{{post.description}}
<app-gallery [postno]={{post.pNo}}></app-gallery>
</mat-expansion-panel>
</mat-accordion>
</div>
但是输出是:
Parser Error: Unexpected token
{
, expected identifier, keyword, or string at column 2 in[{{post.pNo}}]
inng:///AppModule/ForumComponent.html@44:27
("
最佳答案
只要您在帖子内有 pNo,这应该有效
<div class="news" *ngFor="let post of list">
<mat-accordion class="accordion">
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title >{{post.title}}</mat-panel-title>
<div class="w3-right">
<mat-panel-title >{{post.date}}</mat-panel-title>
</div>
</mat-expansion-panel-header>
{{post.description}}
<app-gallery [postno]="post?.pNo"></app-gallery>
</mat-expansion-panel>
</mat-accordion>
</div>
关于node.js - 如何将从数据库获取的postno(帖子编号ID)发送到另一个组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56011181/