File

src/app/layouts/layouts-utils/nav-dropdown.directive.ts

Metadata

selector .nav-dropdown

Index

Methods

Constructor

constructor(el: ElementRef)
Parameters :
Name Type Optional Description
el ElementRef

Methods

toggle
toggle()
Returns : void
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];

results matching ""

    No results matching ""