Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Patch value is not setting the value to the mat-select

I have a mat-select dropdown in a form along with many other controls. I did patch value after getting from DB. Everything is getting mapped except for mat-select.

UI Code

<mat-label>Select an option</mat-label>
<mat-select formControlName="organization"  >
   <mat-option [value]="0">None</mat-option>
   <mat-option [value]="1">Bank Operations (Mike Conticello)</mat-option>
   <mat-option [value]="2">Brokerage product Services (Kent Clark)</mat-option>
   <mat-option [value]="3">Custody & Asset Services ( Staci Sullivan)</mat-option>
</mat-select>

TS code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

this.nominationSvc.GetNominationById(this.id)
  .then(
    result => {
        if (result != null) {
          console.log(result.organization);
          this.nominationForm.patchValue(result);
          }
        }
    });

>Solution :

As the organization value in result was a string,

Change the mat-option value to string

 <mat-select formControlName="organization"  >
    <mat-option [value]="'0'">None</mat-option>
    <mat-option [value]="'1'">Bank Operations (Mike Conticello)</mat-option>
    <mat-option [value]="'2'">Brokerage product Services (Kent Clark)</mat-option>
    <mat-option [value]="'3'">Custody & Asset Services ( Staci Sullivan)</mat-option>
 </mat-select>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading