angularngx-bootstrapngx-bootstrap-modal

Execute code after modal popup fully loaded in angular


I'm using ngx-bootstrap/modal

import { BsModalRef, BsModalService, ModalOptions } from 'ngx-bootstrap/modal';
   
constructor(private modalService: BsModalService) {}
    
this.modalService.show(this.Content, { ariaLabelledBy: 'modal-basic-title', keyboard: false, backdrop: 'static', }).result.then((result: LinkDetail) => {

Here i'm getting

Property 'result' does not exist on type 'BsModalRef'

any solution to fix this issue because i want to execute some lines of code after modal is fully loaded

thanks


Solution

  • I think the open is synchronous and there is no need to wait for any promise. I checked the source code for show method.

    You can simply put the logic inside a setTimeout, which will happen after the modal opens.

    import { BsModalRef, BsModalService, ModalOptions } from 'ngx-bootstrap/modal';
       
    constructor(private modalService: BsModalService) {}
        
    this.modalService.show(this.Content, { ariaLabelledBy: 'modal-basic-title', keyboard: false, backdrop: 'static', });
    
    setTimeout(() => {
        // write your logic here!
    });