前提・実現したいこと
Angular2.0、mat-paginatorのonPaginateChange($event)"イベントで、
ダイアログを表示し、ページ遷移を抑止したい。
どなたか、解決策等をご教示ください。
発生している問題
dialog() で表示するが非同期となり、ページ遷移が走った後にダイアログが表示される。
期待値としては、ダイアログ表示後のボタンイベントでページ遷移を行いたいと思います。
該当のソースコード
Html
1<mat-paginator [pageSize]="api.mnpageSize" [length]="api.mnlength" [pageIndex]="api.mnpageIndex" [hidePageSize]="api.mnhidePageSize" showFirstLastButtons (page)="pageEvent = $event; onPaginateChange($event)"></mat-paginator> 2
TypeScript
1 // 次頁、前頁、先頭頁、最終頁ボタン押下イベント処理 2 onPaginateChange(event: any) { 3 this.dialog(); 4 this.selection.clear(); 5 let offset = 0; 6 offset = event.pageIndex * event.pageSize; 7 this.current_offset = offset; 8 this.current_pageSize = event.pageSize; 9 this.api.mnpageIndex = event.pageIndex; 10 this.onClickUpdate(); 11 } 12 13 dialog() { 14 let dialog = this.matDialog.open(CommonDialogComponent, { 15 'data': { 'title': 'ページ遷移します', 'content': 'よろしいですか?', 'button': "テスト" }, 16 'height': '237px', 17 'width': '480px', 18 'disableClose': true, 19 'autoFocus': true 20 }); 21 dialog.afterClosed().subscribe((result) => { 22 if (result == 'ok') { 23 } else { 24 } 25 }); 26 } 27 28
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/22 05:37