Skip to content

handleDisplayFn not working when value is selected by default #3286

Open
@pacocom

Description

@pacocom
  zzz = [
    { id: 1, v: 'santi' },
    { id: 2, v: 'olga' },
    { id: 3, v: 'pedro' },
    { id: 4, v: 'pepe' },
  ];
  aaa = new FormControl({ id: 1, v: 'santi' });

  handleDisplayFn2 = (value: T | string): string => {
    if (typeof value === 'string') {
      return value;
    }

    return get(value, 'v', ''); // example: {id: 1, v: "santi" } --> "santi"
  };
input [formControl]="aaa" #autoInput2 [nbAutocomplete]="auto2" [focusInputOnValueChange]="false" />

<nb-autocomplete #auto2 (selectedChange)="handleSelectionChange($event)" [handleDisplayFn]="handleDisplayFn2">
  @for (z of zzz; track z.v) {
    <nb-option [value]="z">
      {{ z | get: 'v' }}
    </nb-option>
  }
</nb-autocomplete>

When I started input text should be "santi" but [Object Object] is write in input

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions