引导导航栏不存在于ngx-bootstrap组件列表中。请帮我实现它。
答案 0 :(得分:45)
没有将navbar实现为单独的组件,但可以使用Collapse Module完成。
示例= https://stackblitz.com/edit/ngx-bootstrap-rc8ab4?file=app%2Fapp.component.ts
MODULE
// App imports
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { CollapseModule } from 'ngx-bootstrap/collapse';
@NgModule({
imports: [ BrowserModule, CollapseModule.forRoot()],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
TS(摘录)
export class AppComponent {
isCollapsed = true;
}
HTML
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" (click)="isCollapsed = !isCollapsed" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="collapse navbar-collapse" [collapse]="isCollapsed">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
</div>
</div>
</nav>
答案 1 :(得分:1)