Created
September 18, 2020 04:43
-
-
Save jcamilom/6df508d6a17f4e49d17e93b153e9a0c6 to your computer and use it in GitHub Desktop.
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
export class MultiCheckFieldComponent implements ControlValueAccessor { | |
_onChange: (_: any) => void; | |
registerOnChange(fn: any): void { | |
this._onChange = fn; | |
} | |
private add(value: any): void { | |
this.selectedValues.push(value); | |
this._onChange(this.selectedValues); | |
} | |
private remove(value: any): void { | |
const idx = this.selectedValues.findIndex(v => v === value); | |
if (idx >= 0) { | |
this.selectedValues.splice(idx, 1); | |
this._onChange(this.selectedValues); | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment