typescriptionic3angular5nebular

ngx-admin error when using multiple popovers


I am using ngx-admin NbPopover, 4 attachments per page. I want to close the event when the event is finished.

@ViewChild (NbPopoverDirective) popverDirective: NbPopoverDirective;
this.popverDirective.hide();

I can only use one of them. others are not working. Could your help ?


Solution

  • If you have multiple NbPopoeverDirectives you can get them with @ViewChildren so try the follwing code:

    @ViewChildren(NbPopoeverDirective) popovers: QueryList<NbPopoeverDirective>;
    
    ...
    
    hidePopups(){
      if(this.popovers){
         this.popovers.forEach(popover => {
            popove.hide();
          });
      }
    }