I am querying a API and getting the data back in a array. I am not sure how to set the data source for the Select/dropdown box from the Data response back from the API. My model class is
export class sProject {
Id: string;
prj_number: string;
emp_number : string;
}
My Component is like
export class RFComponent implements OnInit {
sList: sProject[];
entityUrl = 'sDetail/GetByRP?Prj=345';
constructor(service: DataService) {
service.get<sProject[]>(this.entityUrl).subscribe(x =>
{this.stList = x });
}
ngOnInit() { }}
The data is in the sList
array, I am not sure how I can set the datasource for my select/dropdown box
<div class="dx-fieldset">
<div class="dx-field">
<div class="dx-field-label">ShipTo Account</div>
<div class="dx-field-value">
<dx-select-box></dx-select-box>
</div>
</div>
</div>
I am using the devextreme library here, I am trying to see all the prj_number in the dropdown box.
According to the devextreme website Try this:
<dx-select-box [dataSource]="sList" displayExpr="prj_number "></dx-select-box>
Hope it works.