import { SidebarNavigationComponent } from './navigation.component' ; import { EventEmitter , Injectable } from '@angular/core' ; import { BehaviorSubject } from 'rxjs' ; @ Injectable ( ) export class SidebarNavigationService { container : SidebarNavigationComponent ; visibleChange : EventEmitter < boolean > = new EventEmitter < boolean > ( ) ; isOpened$ : BehaviorSubject < boolean > = new BehaviorSubject ( false ) ; setContainer ( container ) { this . container = container ; } toggle ( ) { this . isOpened$ . next ( ! this . isOpened$ . getValue ( ) ) ; } isVisible ( ) { return this . container ? ! this . container . hidden : false ; } setVisible ( value ) { if ( this . container ) { this . container . setVisible ( value ) ; this . visibleChange . emit ( value ) ; } } }