Skip to content

mat-select: Angular mat-option multiple values #27421

@henafufa

Description

@henafufa

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

I have object looks like this

allTransactionAccount = [
{ form_name: 'All Accounts', net_value: -145017687853.47995, vault_user_form_id: 0 },
{ form_name: 'Credit Card 363636363', vault_user_form_id: 18215, net_value: '-455.15' },
];

    <mat-form-field>
      <mat-select>
        <mat-option *ngFor="let account of allTransactionAccount" [value]="account.form_name">
          <div class="flex justify-between">
            <span>
              {{ account.form_name | truncateStrPipe : 25 }}
            </span>
            <span>
              {{ account.net_value | currency : 'USD' : true : '1.0-2' }}
            </span>
          </div>
        </mat-option>
      </mat-select>
    </mat-form-field>

As you see I set the value to account.form_name
I wanted to be only the form_name will be displayed when option item get selected
but I am getting like both form_name and net_value like this
All Accounts - -145017687853.47995

I circled it with red

Screen Shot 2023-07-08 at 4 35 46 AM

Reproduction

StackBlitz link:
Steps to reproduce:
1.
2.

Expected Behavior

I wanted to be only the form name get populated as value to mat-select, and I wanted the net value to only show it the drop down.

When mat-option list selected I want form-name to get populated as it shown on picture

Screen Shot 2023-07-08 at 4 40 54 AM

Actual Behavior

Screen Shot 2023-07-08 at 4 35 46 AM

Environment

  • Angular:
  • CDK/Material:
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu):

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions