1 year ago
#264829
Alice
How to avoid search trigger on enter when autocomplete is going to be used? ANGULAR HTML
I am trying to have an autocomplete with enter and then be able to search with enter for my input. How can I not trigger the search with enter when an autocomplete should be chosen? At the moment, both are triggered at the same time, already after first chosen autocomplete.
HTML:
<input placeholder="Addera kompetenser..." #competenceInput [formControl]="competenceCtrl" [matAutocomplete]="auto" [matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes" (keydown.enter)="serachTriggerEnter()" (matChipInputTokenEnd)="add($event)">
TS:
separatorKeysCodes: number[] = [ENTER];
serachTriggerEnter() {
this.searchCompetences();
}
add(event: MatChipInputEvent): void {
const value = event.value
this.addToArray(value);
event.chipInput!.clear();
this.competenceCtrl.setValue(null);
}
If you want me to add information to make it easier to understand my question, please do not hesitate to ask me!
Thanks in advance.
html
angular
autocomplete
enter
0 Answers
Your Answer