ng2-bootstrap-base-modified
Version:
Native Angular Bootstrap Components Typeahead modified
51 lines (40 loc) • 1.36 kB
text/typescript
import {
Directive, ElementRef, Host, HostBinding, HostListener, Input, OnInit
} from '@angular/core';
import { DropdownDirective } from './dropdown.directive';
/** Mark element which can toggle dropdown visibility with this directive */
export class DropdownToggleDirective implements OnInit {
/** if true dropdown toggle will be disabled */
public isDisabled:boolean = false;
/** if true the dropdown-toggle class will be added to the element */
public addToggleClass:boolean = true;
public addClass:boolean = true;
public dropdown:DropdownDirective;
public el:ElementRef;
public constructor( dropdown:DropdownDirective, el:ElementRef) {
this.dropdown = dropdown;
this.el = el;
}
public ngOnInit():void {
this.dropdown.dropDownToggle = this;
}
public get isOpen():boolean {
return this.dropdown.isOpen;
}
public toggleDropdown(event:Event):boolean {
event.stopPropagation();
if (!this.isDisabled) {
this.dropdown.toggle();
}
return false;
}
}