0

i need to set preselect dropdown on edit. I am using reactive forms. Check my code:

1 Answer 1

1

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"
>
Sign up to request clarification or add additional context in comments.

2 Comments

try to replace [ngValue] by [value] ?
Hmmm no work...there is maybe somethink another problem..

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.