I am using bootstrap 4 modal in my angular app(v6):
CODE:
<div class="container">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Open
</button>
<!-- The Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
Modal body..
</div>
</div>
</div>
</div>
</div>
Now i will open the modal by clicking open button. This works fine.But instead of opening it manually, On clicking open button i need call method/function for ex:
open() {
if('Some condition'){
// Don't open the modal
} else {
// Open the modal
}
}
In the open() method if condition fails modal should open, else should not.How can i achieve this using only typescript