Bootstrap Modal immediately disappearing

后端 未结 27 1117
清歌不尽
清歌不尽 2020-12-04 07:18

I\'m working on a website using bootstrap.

Basically, I wanted to use a modal in the home page, summoned by the button in the Hero Unit.

Button code:

27条回答
  •  Happy的楠姐
    2020-12-04 07:43

    while working with Angular(5) , i face the same issue , but in my case i solved as follows:

    component.html

    
    
    
    

    component.ts

    NOTE: need to import jquery in ts file as "declare var $ :any;"

      showresult(){
        debugger
        $('#myModal').modal('show');
      }
    

    Changes i made :

    • removed "data-toggle="modal" from Button tag (thanks to @miCRoSCoPiC_eaRthLinG this answer helps me here) in my case its showing modal so i created (click)="showresult()"

    • inside component.ts need to declare Jquery($) and inside button click method showresult() call " $('#myModal').modal('show');"

提交回复
热议问题