2

I have added the following code in my HTML file for implementing the bootstrap dropdown, But I am not able to see the dropdown.

HTML file

      <div class="tools text-muted d-flex justify-content-around mr-4">
        <div class="pr-3 border-right">Filter</div>
        <div class="dropdown">
          <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            Filter
          </button>
          <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
          </div>
        </div>
        <fa-icon class="pr-3" [icon]="faChevronDown"></fa-icon>
      </div>
      <button type="button" class="btn btn-warning">Register</button>
    </div>

I have added the bootstrap in angular.json styles array too:

 "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js",
              "src/assets/js/custom.js"
            ]

I am not bale to see the dropdown menu here, I am able to see the button but not the dropdown menu.

2 Answers2

0

it works for me when i simply added the CDN file links to my HTML document ( without using anything else)

Med Okl
  • 74
  • 7
0

Bootstrap's dropdowns require Popper.js. I don't know if you have added it in your dependencies in the package.json, but if you don't, add it there or add it via npm install. You can have a look here. If you have installed Popper.js, your angular.json should look like this:

  "styles": [
    "node_modules/bootstrap/dist/css/bootstrap.min.css",
    "src/styles.css"
  ]
  "scripts": [
    "node_modules/jquery/dist/jquery.min.js",
    "node_modules/popper.js/dist/umd/popper.min.js",
    "node_modules/bootstrap/dist/js/bootstrap.min.js",
    "src/assets/js/custom.js"
  ]
Fab2
  • 179
  • 1
  • 10