mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-04-18 14:22:35 +00:00
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
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({
|
|
selector : 'fuse-navigation',
|
|
templateUrl : './navigation.component.html',
|
|
styleUrls : ['./navigation.component.scss'],
|
|
encapsulation: ViewEncapsulation.None
|
|
})
|
|
export class FuseNavigationComponent implements OnInit
|
|
{
|
|
@Input()
|
|
layout = 'vertical';
|
|
|
|
@Input()
|
|
navigation: any;
|
|
|
|
// Private
|
|
private _unsubscribeAll: Subject<any>;
|
|
|
|
/**
|
|
* 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);
|
|
});
|
|
}
|
|
}
|