Suppose to have a dropdown where the all values are loaded from an assets. this is my json file:
"students": [{
"id": "1",
"name": "Allan"
},
{
"id": "2",
"name": "Spago"
}
],
"students_select": {
"id": "2"
},
I call my service and it print me correct values:
this.fakeService.getDetail().subscribe((result) => {
if (Utility.isNotNull(result)) {
this.detail= result;
}
})
and in my html I do:
<p-dropdown [options]="detail['students']" [(ngModel)]="detail['student_select']" optionLabel="name"></p-dropdown>
the problem is that my values in dropdown are show correct but the only problem is that the value that must be show at the start is "student_select
", but it show the first value "id=1 and name=allan
". My api cannot be "id:2 and "name": "Spago""
because the correct way to return selected item is id. Anyone can help me to resolve this problem?