0

This is my app - My app How can I write in Java/Visual Studio that in my app when I click on "Upgrade" for the id 1, the "Account" row, to appear CASH - the default value? For now it doesn't appear any value.

I make this enum in Java:


public enum Account {
    CASH{
        @Override
        public String toString() {
            return "Cash";
        }
    },
    CARD{
        @Override
        public String toString() {
            return "Card";
        }
    },
}

And this field form in Visual Studio :

 <mat-form-field appearance= "fill" style="margin: 10px 20px 10px 20px">
            <mat-label>Account</mat-label>
            <mat-select>
              <mat-option value="account" type= "text" formControlName="account">CASH</mat-option>
              <mat-option value="account" type= "text" formControlName="account">CARD</mat-option>
            </mat-select>
          </mat-form-field>

Thanks !

  • Does this answer your question? [Use of Enums in Angular 8 HTML template for \*ngIf](https://stackoverflow.com/questions/59289095/use-of-enums-in-angular-8-html-template-for-ngif) – Vikas May 26 '23 at 04:53
  • https://stackoverflow.com/questions/50650790/set-default-option-in-mat-select/50651134#50651134 – Vikas May 26 '23 at 04:54
  • https://www.telerik.com/blogs/angular-basics-working-enums – Vikas May 26 '23 at 04:54

1 Answers1

0

check https://material.angular.io/components/select/examples#select-initial-value. You need to use a default [(value)] in your mat-select attribute. Example explain this very well. Good luck!

dannyRouge
  • 61
  • 5