clr-angular-static-fix
Version:
1. Install Clarity Icons package through npm:
30 lines (25 loc) • 1.02 kB
text/typescript
/*
* Copyright (c) 2016-2018 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
import { AfterViewInit, Directive, ElementRef, Renderer2 } from '@angular/core';
import { ClrDropdown } from './dropdown';
import { RootDropdownService } from './providers/dropdown.service';
({ selector: '[clrDropdownItem]', host: { '[class.dropdown-item]': 'true' } })
export class ClrDropdownItem implements AfterViewInit {
constructor(
private dropdown: ClrDropdown,
private el: ElementRef,
private _dropdownService: RootDropdownService,
private renderer: Renderer2
) {}
ngAfterViewInit() {
this.renderer.listen(this.el.nativeElement, 'click', () => this.onDropdownItemClick());
}
onDropdownItemClick(): void {
if (this.dropdown.isMenuClosable && !this.el.nativeElement.classList.contains('disabled')) {
this._dropdownService.closeMenus();
}
}
}