I'm having a lot of difficulty trying to use Angular Material, specifically with regards to the Selection List. I am displaying a list of objects in a Angular Material Selection List and I want to get the objects from the list of selected items.
This is what I have so far, but [value]="row" just gives me true when I call rows.selectedOptions.selected[0].value:
submit(rows) {
console.log(rows);
console.log(rows.selectedOptions.selected[0].value);
console.log(rows.selectedOptions.selected[0]._getHostElement().innerText); // ugly hack, but at least it gives me the text of the option
}
<md-selection-list #rows dense>
<md-list-option *ngFor="let row of config.data" [value]="row">
{{row.title}}
</md-list-option>
</md-selection-list>
<div class="d-flex justify-content-end">
<div class="p-2">
<button md-button (click)="submit(rows)">
<span>Submit</span>
<md-icon aria-label="submit">arrow_forward</md-icon>
</button>
</div>
</div>
How can I get the actual row from the list of selected options?