Search code examples
angularpopoverng-bootstrap

How can I put a delay on the closing of this ngbPopover?


I am working in Angular7 using ngbootstrap. I need to delay the closing of this ngbPopover for a few seconds while i switch out the content in it and confirm the action w the user. I know how im going to handle the content but can't figure out how to delay it from the template. do i need to call it from the DOM in the .ts file? this closes it fine, but immediately. again, i want to delay the close while i show a feedback message.

was hoping i could use setTimeout in the template. no luck

According to ngbootstrap docs, the delay param/input only works when not using a manual trigger (this is considered a manual trigger by the docs) and the close method does not seem to accept and params.

<button
    (click)="doAThing(); myPop?.close()"
>

thanks in advance


Solution

  • (click)="doAThing(myPop)"
    

    in .ts:

    doAThing(myPop) {myPop.close()}
    

    here you can easily setTimeout