angularbootstrap-modalbootstrap-5

Bootstrap 5 Modal not showing


I have included Bootstrap 5 as a Nuget package and trying to set up a modal on a page. Other aspects of Bootstrap 5 are working as intended.

  <div class="col-12">
  <button type="button" class="btn entry-button" data-bs-toggle="modal" data-bs-target="#logInModal">Log In</button>
  <div class="modal" id="logInModal">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          It works
        </div>
        <div class="modal-body">
          It works
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
  <button type="button" class="btn entry-button">Create Account</button>
</div>

I am doing this in an Angular project with an ASP.NET back end.

Edit: The button appears fine in the window and I can click it, and there's no errors occurring in the console.

I haven't played around with the 'index.html' file. This is it:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>ActreelClient</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root></app-root>
</body>
</html>

All the other bootstrap features work fine.


Solution

  • I simply went to the angular.json file and added a reference to the bootstrap.js file in the scripts section.

    "scripts": [
      "scripts/bootstrap.js"
    ]