我在每行数据生成一个下拉列表:
<ng-container matColumnDef="status_change">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Change Status</th>
<td mat-header *matCellDef="let row">
<mat-form-field>
<form [formGroup]="sitStatus">
<mat-select (click)="updateUnitSituationStatus()" formControlName="sitStatusControl" placeholder="Change Status To">
<!-- <mat-option [value]="row.unit_sprotection_status">{{row.unit_sprotection_status}}</mat-option> -->
<mat-option *ngIf="row.unit_sprotection_status!='Active'" value="Active">Active</mat-option>
<mat-option *ngIf="row.unit_sprotection_status!='Inactive'" value="Inactive">Inactive</mat-option>
</mat-select>
</form>
</mat-form-field>
</td>
</ng-container>
我添加了一个事件来获取更改后的下拉列表的值。换句话说,如果我更改了第 4 行的下拉列表的值,我需要更改值和行的 id,这样我才能更新我的数据库。
我使用(click)
了事件,但是出现了错误:
错误类型错误:无法读取 UnitEditComponent.push 处未定义的属性“值”
这是方法:
updateUnitSituationStatus(){
console.log(this.formGroup.controls['sitStatusControl'].value);
}
我尝试使用(change)
事件,但也没有任何反应。