How to click on html button from the type script file in Angular 2 ? Some time we need to click into a button from the ts File to run one action, to do this you can try this solution (even if it is a hidden button) :

Solution :

<button id="openModalButton" [hidden]="true" data-toggle="modal" data-target="#myModal">Open Modal</button>

On ts File use the code to “click” the button to open the modal :


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


  1. Pingback: Solution for : How to have a default option in angular 2+ » JavaTuto

  2. Pingback: Angular : HTML to PDF with htm2canvas and jsPDF » JavaTuto

Laisser un commentaire