1

テンプレートは次のとおりです。

  <tr *ngFor="let row of rows; let i = index">
     <div (click)=""edit(row)></div>
  </tr>

コンポーネントは次のとおりです。

 public edit(row: PostAddress): void {
      dialogRef.afterClosed().subscribe((postaddress) => {
            if (postaddress) {
                row = postaddress;
                 this._change.markForCheck();
            } 
 }

変数が新しい値に変更されていることがわかります row = postaddress;が、テンプレートはレンダリングされません。

私が使う changeDetection: ChangeDetectionStrategy.OnPush

また、私はこれを試しました:

 row = postaddress;
 this._change.markForCheck();
 this._change.detectChanges();
4

2 に答える 2