<button class="navbar-toggler" type="button" (click)="navbarCollapsed = !navbarCollapsed" [attr.aria-expanded]="!navbarCollapsed" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<!-----------------------------HTML-------------------------------->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<div class="navbar-brand">
<a href="home">
<i class="bi bi-bootstrap-fill"></i>
</a>
</div>
<button type="button" class="navbar-toggler" (click)="isCollapsed = !isCollapsed">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" [ngbCollapse]="isCollapsed">
....
</div>
</div>
</nav>
<!-----------------------------typescript-------------------------------->
isCollapsed : boolean = false;
<div class="collapse navbar-collapse" [ngbCollapse]="navbarCollapsed" id="navbarSupportedContent">