3

Here is the stackblitz of the component/problem reproduced.

I've built a custom input component that:

  1. takes an array of user objects for typeahead filtering
  2. displays your selections as tags
  3. 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?

1 Answer 1

1

The error seems to be in your addTag() function. You're trying to access a parameter that doesn't exist in your typeaheadSource. Change the contact.userId to contact.id and you should be good to go.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.