Instead of using angular2-bootstrap or ng2-bs3-modal as recommended in the discussions on Angular 2 Bootstrap Modal and Angular 2.0 and Modal Dialog, I want to explore other options.
I understand how the Bootstrap modal opens and closes:
- The display property switches between
display: none;
anddisplay: block;
- An attribute toggles on the
div
betweenaria-hidden="true"
andaria-hidden="false"
My initial thought was to bind to the aria-hidden
attribute like this: [aria-hidden]="true"
, but unfortunately, I found out that I cannot bind to aria-hidden
because it is not a recognized property of the div
element (note: attr.aria-hidden
does not exist).
It is known that with jQuery, the Bootstrap modal can be controlled with $('#myModal').modal()
, as highlighted in this question: How to open a Bootstrap modal window using jQuery?
So, my question is: Is there a TypeScript function that has a similar functionality to modal()
in jQuery? Or, is there a way to bind a function or variable to aria-hidden
?
Here is the snippet of my current html
:
<div id="createAccountModal" class="modal fade customForm" role="dialog" [aria-hidden]="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4>Create account</h4>
</div>
<div class="modal-body">
<p>Lorem ipsum</P>
</div>
<div class="modal-footer align-left">
My custom footer
</div>
</div>
</div>
</div