my previous question was not clear. Allow me to ask again clearly as I'm struggling complete my task.
I've mat-table along with checkbox for every row. (No master checkbox). whenever I select the row I should send the values of the selected row to button which is outside of the table.
[if I have a button inside the table, I could do that by accessing the default ELEMENT from *matCellDef="let element"
variable if the button present inside the table.
But I don't know how to pass the selected row value to the button. I've to do routing based on the value from the selected row.
so far I've.
HTML
<div><button mat-button [disabled]="!checkedbtn" (click)='linktomynxtpage()'>link to another page</button></div>
<table #demoTable mat-table [dataSource]="sample" multiTemplateDataRows>
// some ng-container with <th><td>
<ng-container *ngIf="isAdmin" matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef> Action </th>
<td mat-cell *matCellDef="let element">
<mat-checkbox class="select-checkbox" [(ngModel)]="checkedbtn" ></mat-checkbox>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row style="text-align:left" *matRowDef="let element; columns: displayedColumns;" ></tr>
<tr mat-row *matRowDef="let row; columns: ['expandedDetail']" class="detail-row"></tr>
</table>
TS
linktomynxtpage(){
//some logics
//passing row value. and doing routing
this.nxtPage.navigate(['/home/particular-user'])
}
use the (change)
event
<mat-checkbox class="select-checkbox" [(ngModel)]="checkedbtn" (change)="onChange(element)" ></mat-checkbox>
onChange(row){
// put the row whenever you want
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.