File

src/app/layouts/main-layout/dropdown.directive.ts

Metadata

selector [sidebarDropdown]

Index

Properties
Methods
HostBindings
HostListeners

HostBindings

class.open
class.open:

HostListeners

click
Arguments : '$event.target.className'
click(srcClass: )

Methods

close
close()
Returns : void

Properties

Private isOpen
isOpen:
Default value : false
Private targetClassName
targetClassName:
Default value : "nav-link nav-dropdown-toggle"
import {Directive, HostBinding, HostListener} from "@angular/core";

@Directive({
  selector: '[sidebarDropdown]',
  exportAs: 'sidebarDropdown'
})
export class DropdownDirective {

  private targetClassName = "nav-link nav-dropdown-toggle";
  private isOpen = false;

  @HostBinding('class.open') get opened() {
    return this.isOpen;
  }

  @HostListener('click', ['$event.target.className']) open(srcClass) {
    if (srcClass === this.targetClassName) {
      this.isOpen = !this.isOpen;
    }
  }

  close() {
    this.isOpen = false;
  }

}

results matching ""

    No results matching ""