0

I am using a selectbox to select a name from a list.

I am trying to put a source value in the selectbox using the value but nothing is appearing to me. Does anyone know how I can submit a root name without having to make a selection?

Demo

html

  <div *ngFor="let datas of array">
    <dx-select-box [value]="datas.name"> </dx-select-box>
  </div>
John w.
  • 511
  • 1
  • 5
  • 18

1 Answers1

1

That is the incorrect syntax for DevExtreme select box. You need to pass the value to valueExpr and the display value to displayExpr like below. There is no need for ngFor with dx-select-box. Instead, you just need to pass the array to items.

<dx-select-box [items]="array" valueExpr="id" displayExpr="name"></dx-select-box>
nash11
  • 8,220
  • 3
  • 19
  • 55
  • **Note**: On StackBlitz, after pasting the above code in the html, refresh the in-built browser on the right. The StackBlitz auto-refresh does not seem to make it work properly. – nash11 Mar 30 '20 at 16:36
  • displayExpr and valueExpr are for the options in the dx-select-box. Is there a way to set the value of the select-box too, in Angular 8? – Anurag Aug 25 '22 at 10:19