How to use code to open a modal in Angular 2?

前端 未结 14 3043
天涯浪人
天涯浪人 2020-12-05 04:34

Usually we use data-target=\"#myModal\" in the

14条回答
  •  盖世英雄少女心
    2020-12-05 04:50

    This is one way I found. You can add a hidden button:

    
    

    Then use the code to "click" the button to open the modal:

    document.getElementById("openModalButton").click();
    

    This way can keep the bootstrap style of the modal and the fade in animation.

提交回复
热议问题