Check out this Bootstrap Navbar
I recently added the same code to my Angular project, but I'm having trouble getting the dropdown to display properly.
Take a look at the Stackblitz Demo
I need help with two things:
Getting the dropdown to show correctly.
In the original code, the dropdown items were hardcoded.
<div class="dropdown-menu" aria-labelledby="navbarDropdown"> <a class="dropdown-item" href="#">Action</a> <a class="dropdown-item" href="#">Another action</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="#">Something else here</a> </div>
I've now created an array in the component ts file.
this.items = [
{name: 'Action', url: 'app/aaa'},
{name: 'Another Action', url: 'app/bbb'},
{name: 'Something else here', url: 'app/ccc'}
];
I want to use *NgFor
to iterate through the array instead of hardcoding. How can I modify the HTML?