question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dismiss manually doesn't work

See original GitHub issue

Hi, I’m using ngx-smart-modal in an Angular 6/RxJs application to display a confirm dialog. The problem is that it seems you can create just one button, the ‘close’ button, that triggers myModal.close(). So, I thought I could add two buttons to allow the user to confirm or cancel the modal. CANCEL BUTTON:

<button (click)="confirmModal.dismiss()" type="button">{{confirmModal.getData().cancelBtnLabel}}</button>

CONFIRM BUTTON:

<button (click)="confirmModal.close(true)" type="button">{{confirmModal.getData().confirmBtnLabel}}</button>

And then the component where there is the button to open the modal:

openConfirmModal() {    
    const confirmModalData: Object = {
       ...
      };
      this.ngxSmartModalService.setModalData(confirmModalData, 'confirmModal');
      let confirmModalRef = this.ngxSmartModalService.getModal('confirmModal');
      confirmModalRef.onDismiss.subscribe(() => {
        ....
      });
      confirmModalRef.onClose.subscribe((test: boolean) => {
        .....
      });
      confirmModalRef.open();
}

But if I click on cancel button, I have the following error in the console:

ERROR TypeError: Cannot read property 'target' of undefined
    at NgxSmartModalComponent.push../node_modules/ngx-smart-modal/esm5/ngx-smart-modal.js.NgxSmartModalComponent.dismiss

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
panagulis72commented, Jul 25, 2018

Hey @maximelafarie, I was wrong in my application! because I was doing a stackblitz for you, and it works 😄 I forked it, because maybe it could be useful to someone else https://stackblitz.com/edit/angular-k9q4id?file=src/app/confirm-modal/confirm-modal.component.html

1reaction
maximelafariecommented, Jul 25, 2018

Well done @panagulis72! Thank you for the link, for sure it will help! Cheers! 🖖 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

UIContextMenuInteraction : How to Dismiss Manually?
I was interested in the same thing, and calling UIViewController.dismiss(animated:completion:) on the source view controller dismisses it as ...
Read more >
How to make a view dismiss itself - Hacking with Swift
The first option is to tell the view to dismiss itself using its presentation mode environment key. Any view can dismiss itself, regardless...
Read more >
Close an app on your iPhone or iPod touch - Apple Support
Close an app on your iPhone or iPod touch. If an app won't respond or seems frozen, you can close it, then open...
Read more >
Dismissing a pull request review - GitHub Docs
If your repository requires reviews, you can dismiss pull request reviews that are no longer valid or are unable to be approved by...
Read more >
Why You Shouldn't Always Close Apps on Your Android Phone
1. Closing Android Apps Doesn't Increase Your Phone's Battery Life · 2. Your Android Phone Will Not Run Foreground Apps Faster · 3....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found