不为ngIf分配值

时间:2019-08-13 06:34:10

标签: angular7 angular-ng-if

我需要检查ques.id以及传递给component.ts的ID,并在匹配时出示我的垫子卡。但现在可以了

<mat-card *ngFor="let ques of questions | async">
  <div >
    {{ ques.question }}
  </div>
  <div style="text-align:right;">
    <button mat-button color="primary" (click)="showReply(ques.id)" >Show Reply</button>
  </div>

  <mat-card *ngIf="replyState && id== '{ques.id}'">
      <div style="height:30px;">
          <input type="text" >
          <button mat-button (click)="sendReply(ques.id)">Send Reply</button>
        </div>

    <mat-card-content ngFor="let rep of replies">
      reply
    </mat-card-content>

  </mat-card>
</mat-card>

在component.ts

showReply(id){
    console.log(id);
    this.replyState=!this.replyState;
    this.id = id;

    this.frm.getReplies(id).subscribe(next =>{
      next.replies
      this.replies=next.replies
    })
  }

0 个答案:

没有答案