mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 12:35:07 +00:00
Use the navigation service in the fuse-navigation for easier navigation swap
This commit is contained in:
parent
58dd3b93c3
commit
edb4683dcb
|
@ -1,4 +1,8 @@
|
||||||
import { Component, Input, ViewEncapsulation } from '@angular/core';
|
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
|
import { FuseNavigationService } from '@fuse/components/navigation/navigation.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector : 'fuse-navigation',
|
selector : 'fuse-navigation',
|
||||||
|
@ -6,7 +10,7 @@ import { Component, Input, ViewEncapsulation } from '@angular/core';
|
||||||
styleUrls : ['./navigation.component.scss'],
|
styleUrls : ['./navigation.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class FuseNavigationComponent
|
export class FuseNavigationComponent implements OnInit
|
||||||
{
|
{
|
||||||
@Input()
|
@Input()
|
||||||
layout = 'vertical';
|
layout = 'vertical';
|
||||||
|
@ -14,11 +18,37 @@ export class FuseNavigationComponent
|
||||||
@Input()
|
@Input()
|
||||||
navigation: any;
|
navigation: any;
|
||||||
|
|
||||||
|
// Private
|
||||||
|
private _unsubscribeAll: Subject<any>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
constructor()
|
constructor(
|
||||||
|
private _fuseNavigationService: FuseNavigationService
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
// Set the private defaults
|
||||||
|
this._unsubscribeAll = new Subject();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
// @ Lifecycle hooks
|
||||||
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On init
|
||||||
|
*/
|
||||||
|
ngOnInit(): void
|
||||||
|
{
|
||||||
|
// Load the navigation either from the input or from the service
|
||||||
|
this.navigation = this.navigation || this._fuseNavigationService.getCurrentNavigation();
|
||||||
|
|
||||||
|
// Subscribe to the current navigation changes
|
||||||
|
this._fuseNavigationService.onNavigationChanged
|
||||||
|
.pipe(takeUntil(this._unsubscribeAll))
|
||||||
|
.subscribe((key) => {
|
||||||
|
this._fuseNavigationService.getNavigation(key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
<div class="navbar-content" fusePerfectScrollbar
|
<div class="navbar-content" fusePerfectScrollbar
|
||||||
[fusePerfectScrollbarOptions]="{suppressScrollX: true}">
|
[fusePerfectScrollbarOptions]="{suppressScrollX: true}">
|
||||||
<fuse-navigation [navigation]="navigation" layout="vertical"></fuse-navigation>
|
<fuse-navigation layout="vertical"></fuse-navigation>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<ng-container *ngIf="layout == 'horizontal'">
|
<ng-container *ngIf="layout == 'horizontal'">
|
||||||
|
|
||||||
<div class="navbar-horizontal">
|
<div class="navbar-horizontal">
|
||||||
<fuse-navigation [navigation]="navigation" layout="horizontal"></fuse-navigation>
|
<fuse-navigation layout="horizontal"></fuse-navigation>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</ng-container>
|
</ng-container>
|
Loading…
Reference in New Issue
Block a user