I want to make a navbar using Bootstrap 4 and Angular 2 that collapses his content on a button when the width of the browser reaches some value. I achieve this, and when the
This stackblitz shows how you can implement the Bootstrap navbar with the ngbCollapse directive from ng-bootstrap, without using jQuery. The boolean flag isNavbarCollapsed
is defined in the component class and its value is toggled by the button.
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
...
<button class="navbar-toggler" type="button" (click)="isNavbarCollapsed = !isNavbarCollapsed">
<span class="navbar-toggler-icon"></span>
</button>
<div [ngbCollapse]="isNavbarCollapsed" class="navbar-collapse">
...
</div>
</nav>