Closed
Description
Documentation Feedback
The recently added 'Chips with form control' example (#22814, @devversion) does never show any value at 'Selected keywords'. It seems that the formControl never gets updated.
<p>
Selected keywords: {{formControl.value}}
</p>
I made a working example here: https://stackblitz.com/edit/angular-o2zelu?file=src/app/chips-form-control-example.ts, but I'm wondering if it should really be necessary to update formControl manually (like I did in stackblitz example)?
export class ChipsFormControlExample {
formControl = new FormControl(['angular', 'how-to', 'tutorial']);
addKeywordFromInput(event: MatChipInputEvent) {
if (event.value) {
this.formControl.setValue([...new Set([...this.formControl.value, event.value])]);
event.chipInput!.clear();
}
}
removeKeyword(keyword: string) {
this.formControl.setValue([...this.formControl.value].filter((entry) => entry !== keyword));
}
}
Affected documentation page: