0
votes

I'm listing down 1-100 numbers using mat-form-field in mat-option . It is not showing the saved value in the dropdown after saving.**

<mat-form-field class="full-wid" appearance="outline">
                  <mat-label>Percentage 1 (%)</mat-label>
                  <mat-select matTooltip="Please percentage" class="numbers" [required]="percentTorF"
                    (selectionChange)="selected2()" [formControl]="salaryform.controls['Percentage1']"
                    [(ngModel)]="percentValue1">
                    <mat-option *ngFor="let n1 of numbers1" [value]="n1">{{ n1 }}</mat-option>
                  </mat-select>
                  <mat-error *ngIf="salaryform.controls['Percentage1'].hasError('required')">
                    Percentage is required</mat-error>
</mat-form-field>

enter image description here** enter image description here

1
What is the result of {{percentValue1 | json }}? plus show the sample data of numbers1 arrayPrashant Pimpale
it would be better if you can create a stackblitz for it.shashank sharma
public numbers1 = []; for (let i = 1; i <= 99; i++) { this.numbers1.push(i); }Aarya Linga Reddy
Are you using Forms? Reactive?Prashant Pimpale
Yes using reactive forms.Aarya Linga Reddy

1 Answers

0
votes

Convert percentage integer value to string using toString() before filling form values.