Fixed problems with the sidebar service. Switched to use "path" concept instead of component

This commit is contained in:
Ronny Roos 2016-07-06 21:26:34 +02:00 committed by nixa
parent 31efdaa1f1
commit f24546639c
4 changed files with 57 additions and 44 deletions

View file

@ -1,10 +1,9 @@
import {Component, ElementRef, HostListener, ViewEncapsulation} from '@angular/core';
import {Router} from '@angular/router';
import {AppState} from '../../../app.state';
import {layoutSizes} from '../../../theme';
import {BaSlimScroll} from '../../../theme/directives';
import {BaSidebarService} from './baSidebar.service';
import {Component, ElementRef, HostListener, ViewEncapsulation} from "@angular/core";
import {Router} from "@angular/router";
import {AppState} from "../../../app.state";
import {layoutSizes} from "../../../theme";
import {BaSlimScroll} from "../../../theme/directives";
import {BaSidebarService} from "./baSidebar.service";
@Component({
selector: 'ba-sidebar',
@ -35,7 +34,9 @@ export class BaSidebar {
private _state:AppState) {
this.menuItems = this._sidebarService.getMenuItems();
// this._onRouteChange = this._router.root.subscribe((path) => this._selectMenuItem());
this._onRouteChange = this._router.events.subscribe(() => {
this._selectMenuItem();
});
this._state.subscribe('menu.isCollapsed', (isCollapsed) => {
this.isMenuCollapsed = isCollapsed;
});
@ -49,7 +50,7 @@ export class BaSidebar {
}
public ngOnDestroy():void {
// this._onRouteChange.unsubscribe();
this._onRouteChange.unsubscribe();
}
public ngAfterViewInit():void {