Created
June 1, 2020 18:03
-
-
Save Dornhoth/514351ae7aeb92279e987e4e0f14aa3e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export class MultiselectComponent implements ControlValueAccessor { | |
[...] | |
private onChange = (_: Array<ListItem>) => { }; | |
private onTouch = () => { }; | |
@HostListener('document:click', ['$event.target']) | |
public onClick(targetElement) { | |
const clickedInside = this.multiselect.nativeElement.contains(targetElement); | |
if (!clickedInside) { | |
this.closeDropdown(); | |
this.onTouch(); | |
} | |
} | |
@HostListener('blur') | |
public onTouched() { | |
this.closeDropdown(); | |
this.onTouch(); | |
} | |
writeValue(items: Array<ListItem>): void { | |
throw new Error('Method not implemented.'); | |
} | |
registerOnChange(fn: any): void { | |
this.onChange = fn; | |
} | |
registerOnTouched(fn: any): void { | |
this.onTouch = fn; | |
} | |
setDisabledState?(isDisabled: boolean): void { | |
throw new Error('Method not implemented.'); | |
} | |
[...] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment