单击项目后自动折叠导航栏

时间:2017-11-15 11:25:15

标签: angular aspnetboilerplate ngx-bootstrap

我试图在点击链接后自动折叠菜单栏。我使用了下面的代码,但它加载了整个页面,我不想让它重新加载页面。

<div>
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        <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" [routerLink]="'/app/home'">
        <i class="fa fa-cubes"></i> Website
    </a>
</div>
<div class="collapse navbar-collapse">
    <ul class="nav navbar-nav">
        <ng-template ngFor let-menuItem [ngForOf]="mainMenuItems" let-mainMenuItemIndex="index">
            <li *ngIf="showMenuItem(menuItem)" routerLinkActive="active">
                <a data-toggle="collapse" data-target=".in" [routerLink]="[menuItem.route]">
                    <i class="{{menuItem.icon}}"></i>
                    <span class="title hidden-sm">{{l(menuItem.name)}}</span>
                </a>
            </li>
        </ng-template>
    </ul>
</div>

0 个答案:

没有答案