Reputation: 61
I'm new with all of the browser UI tools. I have been working on a simple angular/typescript application. I created an angular application using VS2017 ASP.NET core web application template. I can't get a modal window to show up.
I've seen several answers stating that you need to include jquery and or bootstrap.js. But I don't know where to specify these in this project. I used nuget to install angular, bootstrap and I even installed the jquery and jquery.ui.combined with no luck.
<h1>Hello, world!</h1>
<p>Welcome to your new single-page application, built with:</p>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<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>
I've tried a bunch of different samples for showing a modal but I have not yet had a modal show.
Upvotes: 3
Views: 1000
Reputation: 69
I can confirm this works too with Visual Studio 2019 Angular Template.
Added mentioned scripts in 'angular.json' like :
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css",
"src/assets/fonts/fonts-fontname.css"
],
"scripts": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.min.js"
]
Thank you Tony!
Upvotes: 0
Reputation: 61
I new it was something only a total newbie would not know. I just had to include the jquery and bootstrap scripts in 'angular.json'. I added the following to the "scripts" array.
"scripts": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.min.js"
]
Upvotes: 3