Ng-Select - Set multiple dropdown values

Discussão em 'Angular' iniciado por Hari, Dezembro 9, 2024.

  1. Hari

    Hari Guest

    we are using NG-SELECT trying a create multiple forms with drop-down , we are trying to update the value of all dropdowns when one of the dropdown is updated but unable to find the correct node or configuration option to set it.

    //reusable-form.component.ts
    .. some inputs here
    <ng-select
    [searchable]="false"
    [clearable]="false"
    [(ngModel)]="selectedOption"
    placeholder="search"
    (change)="onSelect($event)"
    >
    <ng-option *ngFor="let data of datas; trackBy:userByName" [value]="data.name">{{
    data.name
    }}</ng-option>
    </ng-select>



    we tried setting the option on change event as below, but the values are updated on rest of the drop-downs

    onSelect(event){
    this.selectedOption = event ; // even though model already has the value in it
    this.cdref.detectchanges();
    }

    Continue reading...

Compartilhe esta Página