How do I get the values of other columns in the row when an event is raised from a mat-select drop down?
Using angular 7 material I need to get the data for all elements in the row of a mat-table in (during) the selectionChanged
event of the mat-select drop down. I can get the selection that changed in the event handler, but I need the values from other columns in the same row in the event handler. Being new to angular I don’t see how to get the data. How do I get the values of other columns in the row that the event was raised from?
.html
<td mat-cell *matCellDef="let element">
<mat-select (selectionChange)="onNotesChange($event)">
<mat-option *ngFor="let item of predefinedNotes" [value]="item.id">
{{item.value}}
</mat-option>
</mat-select>
</td>
.ts
onNotesChange(event:any){
console.log(event);
}
Other answers only show the drop-downs new value, I need other values from the row. For instance there is a usreId column I need the value of in the same row as the mat-select.
Replace [value]="item.id"
with [value]="item"
Try like this:
<mat-option *ngFor="let item of predefinedNotes" [value]="item">
{{item.value}}
</mat-option>