1

I'm trying to load some selects with predefined values in angular reactive form, But initial value is not showing up.

These values are objects. Don't know if this has any effect on the issue.

Below is the sample Stackblitz on this:

https://stackblitz.com/edit/angular-ivy-xrapce?file=src%2Fapp%2Fselect-form%2Fselect-form.component.ts

Thanks for any advise.

1 Answer 1

1

You should use compare function like this:

<select [compareWith]="compareFn" 

and then:

compareFn = this._compareFn.bind(this);

_compareFn(a, b) {
  return a.id === b.id;
}
Sign up to request clarification or add additional context in comments.

1 Comment

had to add nullcheck but thats totaly the right answer

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.