-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(select): clicking on the input now causes the item list to appear (…
…#154) * fix(README): Update docs with correct selector ng-select (#148) * fix(select): clicking on the input now causes the item list to appear * fix(select): tslint & merge errors
- Loading branch information
Showing
3 changed files
with
43 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {Directive, HostListener, Input, OnInit, OnDestroy} from 'angular2/core'; | ||
|
||
@Directive({ | ||
selector: '[offClick]' | ||
}) | ||
|
||
export class OffClickDirective implements OnInit, OnDestroy { | ||
/* tslint:disable */ | ||
@Input('offClick') public offClickHandler: any; | ||
/* tslint:enable */ | ||
@HostListener('click', ['$event']) public onClick($event: MouseEvent): void { | ||
$event.stopPropagation(); | ||
} | ||
|
||
public ngOnInit(): any { | ||
setTimeout(() => {document.addEventListener('click', this.offClickHandler);}, 0); | ||
} | ||
|
||
public ngOnDestroy(): any { | ||
document.removeEventListener('click', this.offClickHandler); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters