Skip to content

How to make a dynamic sidebar menu? #107

@dolgovnv

Description

@dolgovnv

I want to make a dynamic sidebar menu. For the test, I created a method changeMenu() in default-layout.component.ts.

I made the following changes (coreui-free-angular-admin-template-2.0.0-rc.4):

default-layout.component.html
<a class="nav-link" href="#" (click)="changeMenu()">Dashboard</a>

default-layout.component.ts
public changeMenu() { this.navItems = [ { name: 'Dashboard', url: '/dashboard', icon: 'icon-speedometer', badge: { variant: 'info', text: 'NEW' } } ]; }

I'm changing the array navItems. However, a strange bug occurs. A new item is added to the menu, and the old ones do not disappear.

Screenshot before clicking
001

after clicking
002

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions