onokumus / metismenu

A collapsible jQuery menu plugin
https://onokumus.github.io/metismenu/
MIT License
1.96k stars 487 forks source link

expanded sub menu collapsed when page reload #133

Open hanzoz opened 7 years ago

hanzoz commented 7 years ago

Hey guys,

I am using angular2

navigation.component.ts `import { Component } from '@angular/core'; import {Router} from '@angular/router';

declare var jQuery:any;

@Component({ selector: 'navigation', templateUrl: 'navigation.template.html' })

export class NavigationComponent {

constructor(private router: Router) {}

ngAfterViewInit() {
    jQuery('#side-menu').metisMenu();
}

activeRoute(routename: string): boolean{
    return this.router.url.indexOf(routename) > -1;
}

}`

navigation.template.html `

  • <a routerLinkActive="active" [routerLink]="['/components/buttons']"> AAA

  • mmaneff commented 5 years ago

    Hi, I have the same problem. When I click on an option in my side menu (sidebar-nav), the page is reloaded and the menu collapses again. I need that after reloading the page keep open and selected the option of the chosen menu.

    I am using bootstrap 3, the latest version of metisMenu 2.7.9 - jQuery 3.1.0 - VS 2017 Razor.

    How can I get it?

    From already thank you very much

    ADoosti commented 5 years ago

    You can use like this: <ul class="sub-menu collapse" id="contact" [routerLinkActive]="'in'"> <li [routerLinkActive]="'active'"> <a [routerLink]="['/contact']">contact</a> </li> <li [routerLinkActive]="'active'"> <a [routerLink]="['/main']">main</a> </li> <li [routerLinkActive]="'active'"> <a [routerLink]="['/other']">other</a> </li> </ul>