Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap modal does not show in basic ASP.NET Core Web angular application

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">&times;</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.

like image 705
Tony Avatar asked Jan 21 '26 08:01

Tony


1 Answers

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"
]

like image 97
Tony Avatar answered Jan 24 '26 16:01

Tony



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!