Skip to content

Bug in autoComplete #18286

Closed
Closed
@rezarouzbahani

Description

@rezarouzbahani

Bug

What is the expected behavior?

[viewValue]="option.Name" [value]="option.Id"

What is the current behavior?

[viewValue]="option.Name" [value]="option.Name"

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.

StackBlitz starter: https://goo.gl/wwnhMV

What is the use-case or motivation for changing an existing behavior?

<mat-form-field class="example-full-width">
  <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="myControl"
    [matAutocomplete]="auto">
  <mat-autocomplete #auto="matAutocomplete" (optionSelected)="optionSelected($event)">
    <mat-option *ngFor="let option of diseasesObservable | async" [viewValue]="option.Name" [value]="option.Id">
      {{option.Name}}
    </mat-option>
  </mat-autocomplete>
</mat-form-field>

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

lateast

Is there anything else we should know?

I expect [viewValue]="option.Name" filled in TextBox and [Value]="option.Id" doesn't Fill in TextBox
and in optionSelected($event) have ViewValue (Title for example) and have Value (1 for example )
Notice : [Value]="option.Id" bind to TextBox in html
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions