I am using bootstrap 5 cdn and I want to open the dropdown without clicking on the dropdown.
I use the navigation bar and want to display "drop-down links":
In the component I try to do the following but it doesn't work:
export class AppComponent { open() { const dropdown = document.getElementById('test'); dropdown.click(); } }
I did it in stackblitz: test
Add bootstrap attributes to button:
Link code:https://stackblitz.com/edit/angular-bootstrap-5-dynamic-navbar-77sj13?file=app/app.component.html
It will work, however. Keep in mind that your angular application should control these elements, so mixing external libraries with framework libraries (Angular, Vue, React) will always cause trouble
For this purpose, there are special implementations, for example:https://ng- bootstrap.github.io/#/homeAngle guide
Another option is to use ngIf to show the navigation bar (no animation by default)
Another link:https://stackblitz.com/edit/angular-bootstrap-5-dynamic-navbar-hygpzq?file=app/app.component.html