i need to set preselect dropdown on edit. I am using reactive forms. Check my code:
1 Answer
You bind your option with [ngValue]="test.value" but you set this.test[2] in your formGroup.
Replace : valueTest : [this.test[2]] by valueTest : [this.test[2].value]
Also, replace [ngValue] by [value]
also, you can try this to check was going on :
compareObjects(o1: any, o2: any) {
console.log('o1 : ', o1);
console.log('o2 : ', o2);
return (o1===o2)
}
and
<select
class="form-control"
formControlName="valueTest"
[compareWith]="compareObjects"
>
2 Comments
Gauthier Tassin
try to replace [ngValue] by [value] ?
Michael
Hmmm no work...there is maybe somethink another problem..