I have a sample Angular 12 project with Bootstrap 4. Everything is working in my project except the dropdown.
This SO answer was not working for me.
I have installed jQuery, Popper and Bootstrap in my project using the NPM commands given :
npm install --save @popperjs/core
npm install --save bootstrap
npm install --save jquery
I also referred them from the angular.json :
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/@popperjs/core/dist/umd/popper.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js"
]
I'm getting no error and also dropdown button is coming. But the issue is that the list is not popping up as soon as I clicked.
The sample code is given below that I took from Bootstrap Dropdown Official Docs for testing.
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown button
</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>
Am I missing something which need to be added ?
npm install --save bootstrapit installsBootstrap 5so the sample code for the dropdown button supplied above won't work. Try the following code for the dropdown button