Here is the stackblitz of the component/problem reproduced.
I've built a custom input component that:
- takes an array of user objects for typeahead filtering
- displays your selections as tags
- form control value is an array of the selected users
users[]
The issue is that adding a result (input-tags.component) does not update the form (app.component) and I can't understand why.
input-tags.component.ts
addTag(contact: any) {
...
this.onChange(this.tags); // update controller value
}
app.component.ts
this.form.controls['users'].valueChanges.subscribe(data => {
this.control = data; // always null
});
onChanges is called as expected and everything works fine except the form control is always null. Why?