Reputation: 302
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:
Thanks for any advise.
Upvotes: 1
Views: 961
Reputation: 493
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;
}
Upvotes: 1