我有这张桌子:
<div class="table-container">
<table mat-table [dataSource]="dataSource">
<mat-divider></mat-divider>
<!-- title column -->
<ng-container matColumnDef="title">
<th mat-header-cell *matHeaderCellDef> {{ 'NOTIFYCATION.NOTIFY_TITLE' | translate }} </th>
<td mat-cell *matCellDef="let element"> {{element.title}} </td>
</ng-container>
<!-- code column -->
<ng-container matColumnDef="description">
<th mat-header-cell *matHeaderCellDef> {{ 'NOTIFYCATION.DESCRIPTION' | translate }} </th>
<td mat-cell *matCellDef="let element"> {{element.description}} </td>
</ng-container>
<!-- code column -->
<ng-container matColumnDef="receiverDisplayName">
<th mat-header-cell *matHeaderCellDef> {{ 'NOTIFYCATION.RECEIVER_DISPLAY_NAME'| translate }} </th>
<td mat-cell *matCellDef="let element"> {{element.receiverDisplayName}} </td>
</ng-container>
<!-- code column -->
<ng-container matColumnDef="type">
<th mat-header-cell …Run Code Online (Sandbox Code Playgroud) Input在我的组件中获取列表:
@Input() usersInput: Section[];
export interface Section {
displayName: string;
userId: number;
title: number;
}
Run Code Online (Sandbox Code Playgroud)
这是值列表:
0:
displayName: "???? ???"
firstName: null
lastName: null
title: 0
userId: 1
1:
displayName: "???????? ????????"
firstName: "????????"
lastName: "????????"
title: 0
userId: 2
Run Code Online (Sandbox Code Playgroud)
在ngAfterViewInit我将输入值设置为用户列表:
ngAfterViewInit(): void {
this.users = this.usersInput;
if (this.users.length === 0) {
this.show = false;
} else {
this.show = true;
}
}
Run Code Online (Sandbox Code Playgroud)
这是用户:
users: Section[] = [];
我在 html 列表中使用它:
<div *ngFor="let item of users" class="d-flex …Run Code Online (Sandbox Code Playgroud)