coreui-angular-ex-dev
Version:
CoreUI Components Library for Angular
38 lines (33 loc) • 914 B
text/typescript
import {Directive, HostListener, Input} from '@angular/core';
import {SidebarService} from '../sidebar.service';
/**
* Allows the sidebar to be toggled/folded via click on host element.
*/
export class SidebarToggleDirective {
/**
* Id of sidebar for toggle action. [docs]
*
* @type string
*/
id?: string;
/**
* Sidebar property name for toggle action. [docs]
*
* @type 'visible' | 'unfoldable'
* @default 'visible'
*/
toggle: 'visible' | 'unfoldable' = 'visible'
constructor(
private sidebarService: SidebarService
) {}
toggleOpen($event: any): void {
$event.preventDefault();
this.sidebarService.toggle({ toggle: this.toggle, id: this.id });
}
}