[SOLVED] Popover dismiss anywhere


I have the following code to close all the popovers that are open, before redirecting users to the login page

    private _popoverCtrl: PopoverController
  ) { }

  logout() {

This code only works if there is at least one popover open, but if all are closed, then “dismiss ()” throws the following exception

  ERROR Error: Uncaught (in promise): overlay does not exist

Which is fine, but, how else can I close all the popovers in the logout without knowing exactly if they are or are not open

async logout() {
    if (await this._popoverCtrl.getTop()) this._popoverCtrl.dismiss();
1 Like


thank you