I have a very strange problem. I have an Angular 2 application where I want to display a dialog box on one of the button clicks on one of the components.
Below is the code that I use in the template metadata section and it does not work.
<div class="container">
<h2>Modal Example</h2>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
When I write all this code in an HTML file and use templateUrl in my @Component decorator, the code works fine and I get a dialog when I click a button.
In both cases, I use the following Javascripts links in the index.html file.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
source
share