向按鈕添加引導(dǎo)屬性:
<button class="btn btn-primary btn-sm" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation" > Abrir </button>
鏈接代碼:https://stackblitz.com/edit/angular-bootstrap-5-dynamic-navbar-77sj13?file=app/app.component.html
它會(huì)起作用,但是。請記住,您的角度應(yīng)用程序應(yīng)該控制這些元素,因此將外部庫與框架庫(Angular、Vue、React)混合使用總是會(huì)引起麻煩
對于這種用途,有特殊的實(shí)現(xiàn),例如: https://ng- bootstrap.github.io/#/home 角度引導(dǎo)
另一個(gè)選項(xiàng)是使用 ngIf 顯示導(dǎo)航欄(默認(rèn)情況下沒有動(dòng)畫)
另一個(gè)鏈接: https://stackblitz.com/edit/angular-bootstrap-5-dynamic-navbar-hygpzq?file=app/app.component.html