Conditional popovers

In #737, ngbTooltip was amended to only show a tooltip if the content is not falsy.

I’d like ngbPopover to behave the same way (currently, it shows an empty popover in this case).

Usecase

I’d like to show a different (or no) popover depending on the state of the element being hovered over. I had this working for a tooltip:

  <div [ngbTooltip]="helpKey || invalid ? tooltip : null" placement="bottom"
      triggers="hover focusin:focusout">

but the same approach with a popover

  <div [ngbPopover]="helpKey || invalid ? tooltip : null" placement="bottom"
      triggers="hover focusin:focusout">

shows an empty popover if passed null.

Version of Angular, ng-bootstrap, and Bootstrap:

Angular: 5

ng-bootstrap: 1.0.0

Bootstrap: 4

1 possible answer(s) on “Conditional popovers