Angular 6在下拉列表中添加更改事件会产生一个未定义值的错误
我在每行数据中生成了一个下拉列表:Angular 6在下拉列表中添加更改事件会产生一个未定义值的错误,angular,angular-material,angular6,onchange,event-binding,Angular,Angular Material,Angular6,Onchange,Event Binding,我在每行数据中生成了一个下拉列表: <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 [formGr
<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>
我试图使用
(更改)
事件,但也没有发生任何事情。因为您正在使用sitStatus
表单组
,所以您也应该在该组中查找控件
this.sitStatus.controls['sitStatusControl'].value
由于您在这里使用的是
sitStatus
表单组
,因此您也应该在该组中查找控件
this.sitStatus.controls['sitStatusControl'].value
我还没有尝试过Material UI,但我相信它与普通的
select
<select (change)="onChangeEvent($event)">
<option value="option1">My Options</option>
</select>
我还没有尝试过Material UI,但我相信它与普通的
select
<select (change)="onChangeEvent($event)">
<option value="option1">My Options</option>
</select>
好的,但仍然没有值被安慰,无论是在
上单击
还是在上更改
。使用@Output()选择更改:EventEmitter
,所以它将是(选择更改)
好的,但仍然没有值被安慰,无论是在上单击
还是在上更改
。使用@Output()selectionChange:EventEmitter
因此它将是(selectionChange)