ng-select displaying [object, object]

Discussão em 'Angular' iniciado por DZF, Janeiro 17, 2025.

  1. DZF

    DZF Guest

    I have an array of objects that includes an element with an object and I'm looking to display the name of the object on a selectable dropdown using ng-select. I can console log everything as expected, however when I try to display the data I am only able to show [object, object]. The correct number of objects.

    HTML -

    <ng-select
    [searchable]="false"
    bindValue="id"
    bindLabel="medications.items"
    [items]="selected"
    [(ngModel)]="serviceUsersMedication">
    </ng-select>


    TS -

    onSelect({selected}) {
    this.selected = selected;
    const filteredMeds = this.selected.filter(item => {
    return item.medications;
    });

    this.serviceUsersMedication = filteredMeds.map(item => {
    return item.medications;
    });

    console.log('Selected:');
    console.log(this.selected);
    }


    [​IMG]

    [​IMG]

    Continue reading...

Compartilhe esta Página