johannesjo / angular2-promise-buttons

Chilled loading buttons for angular2
https://johannesjo.github.io/angular2-promise-buttons/#demo
MIT License
86 stars 28 forks source link

It does not work when the button needs to be confirmed #26

Closed hassan-haghi closed 4 years ago

hassan-haghi commented 5 years ago

Hello It does not work when the button needs to be confirmed. for example:

  <button type="button" mat-raised-button class="warn" (click)="deleteRequest(request)"
    [promiseBtn]="submitSubscription">
          Delete 
  </button>

  deleteRequest(request): void {

    this.confirmDialogRef = this.matDialog.open(ConfirmDialogComponent, {
        disableClose: false,
        data: {
            title: 'Confirm',
            message: 'Are you sure you want to deletethis request?'
        }
    });

    this.confirmDialogRef.afterClosed().subscribe(result => {
        if (result) {
            this.confirmDelete(request.requestId);
        }

        this.confirmDialogRef = null;
    });
}

   private confirmDelete(requestId): void {
    this.submitSubscription = this.requestService.delete(requestId)
        .subscribe(resp => {
            .......
        });
}
johannesjo commented 5 years ago

Hey hey. Could you maybe provide a plunkr or stackblitz? Not really sure what is going on in the example you provided :)