Angular 12 - Mat-Dialog 不显示来自 table 的值

Angular 12 - Mat-Dialog does not show the value from table

我正在尝试使用此服务 URI 创建一个简单的 angular 基于 12 的 CRUD 应用程序 - https://api.github.com/repos/angular/angular/issues

我有这样一个模型:

export class Issue {
  id: number;
  title: string;
  state: string;
  url: string;
  created_at: string;
  updated_at: string;
  author_association: string;
}

在 app.component.html 我的 table 组件列是这样的:

    <ng-container matColumnDef="author_association">
        <mat-header-cell *matHeaderCellDef mat-sort-header>Author Association</mat-header-cell>
        <mat-cell *matCellDef="let row"> {{row.author_association}}</mat-cell>
    </ng-container>

数据显示在 table 中,如下所示:

还有两个对话框组件 (delete/edit)。

import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import {Component, Inject} from '@angular/core';
import {DataService} from '../../services/data.service';


@Component({
  selector: 'app-delete.dialog',
  templateUrl: '../../dialogs/delete/delete.dialog.html',
  styleUrls: ['../../dialogs/delete/delete.dialog.css']
})
export class DeleteDialogComponent {

  constructor(public dialogRef: MatDialogRef<DeleteDialogComponent>,
              @Inject(MAT_DIALOG_DATA) public data: any, public dataService: DataService) { }

  onNoClick(): void {
    this.dialogRef.close();
  }

  confirmDelete(): void {
    this.dataService.deleteIssue(this.data.id);
  }
}

import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import {Component, Inject} from '@angular/core';
import {DataService} from '../../services/data.service';
import {FormControl, Validators} from '@angular/forms';

@Component({
  selector: 'app-baza.dialog',
  templateUrl: '../../dialogs/edit/edit.dialog.html',
  styleUrls: ['../../dialogs/edit/edit.dialog.css']
})
export class EditDialogComponent {

  constructor(public dialogRef: MatDialogRef<EditDialogComponent>,
              @Inject(MAT_DIALOG_DATA) public data: any, public dataService: DataService) { }

  formControl = new FormControl('', [
    Validators.required
    // Validators.email,
  ]);

  getErrorMessage() {
    return this.formControl.hasError('required') ? 'Required field' :
      this.formControl.hasError('email') ? 'Not a valid email' :
        '';
  }

  submit() {
    // emppty stuff
  }

  onNoClick(): void {
    this.dialogRef.close();
  }

  stopEdit(): void {
    this.dataService.updateIssue(this.data);
  }
}

问题: 上述两个对话框中都缺少 Author Association 的数据。例如:

问题:我在这里缺少什么?或者我在这里做错了什么?

如果需要,我可以提供更多详细信息。还有就是直接准备-运行project is available here.

startEdit() 函数中缺少

row.author_association。在按钮中添加 row.author_association 单击应该可以解决您的问题

<button mat-icon-button color="accent" (click)="startEdit(i, row.id, row.title, row.state, row.url, row.created_at, row.updated_at, row.author_association)">