[英]how to show confirm when sort in mat-table angular material
我正在使用 angular 8 和 angular 材料 8,我想在墊表上排序時顯示確認。 如果用戶確認真圖標會改變,當確認假假圖標不會改變。 我該怎么做?? 請幫助解決此問題stack-blitz 鏈接
如果我理解正確,您的要求是要求用戶在調用 function 對數據進行排序之前確認排序。
如果是這樣,您有兩個選擇:
這是第二個的例子。 方法:
@Component({
// ...
})
export class TableSortingExample {
@ViewChild(MatSort, { static: true }) sort: MatSort;
lastSort: Partial<Sort> = {};
sortChangeHandler(evt: Sort): void {
if (confirm('Confirm question?')) {
this.lastSort = {
active: this.sort.active,
direction: this.sort.direction
};
// Perform sort operation
} else {
this.sort.active = this.lastSort.active;
this.sort.direction = this.lastSort.direction;
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.