src/app/layouts/layouts-utils/nav-dropdown.directive.ts
Allows the dropdown to be toggled via click.
selector | .nav-dropdown-toggle |
HostListeners |
constructor(dropdown: NavDropdownDirective)
|
||||||||
Parameters :
|
click |
Arguments : '$event'
|
click($event: any)
|
import {Directive, HostListener, ElementRef} from '@angular/core';
@Directive({
selector: '.nav-dropdown'
})
export class NavDropdownDirective {
constructor(private el: ElementRef) { }
toggle() {
this.el.nativeElement.classList.toggle('open');
}
}
/**
* Allows the dropdown to be toggled via click.
*/
@Directive({
selector: '.nav-dropdown-toggle',
})
export class NavDropdownToggleDirective {
constructor(private dropdown: NavDropdownDirective) {}
@HostListener('click', ['$event'])
toggleOpen($event: any) {
$event.preventDefault();
this.dropdown.toggle();
}
}
export const NAV_DROPDOWN_DIRECTIVES = [NavDropdownDirective, NavDropdownToggleDirective];
// export const NGB_DROPDOWN_DIRECTIVES = [NgbDropdownToggle, NgbDropdown];