I have a json object as below :
dataset: Dataset[] = [
{
serviceType: "server Mangemanet",
serviceValues: [
"6.2",
"6.3",
"6.6"
]
},
{
serviceType: "server admin",
serviceValues: [
"4.1",
"4.2",
"4.6"
]
},
];
and i have two drop downs so that the value in thesecond one should be displayed based on the value selected in first dropdown . In first drop down i will select the servicetype and in the second dropdown the corresponding service values should appear. iam trying to do it this way :
<td>
<select [(ngModel)]="data2" placeholder="select a value" (change)="data2 = dataset[idx];" >
<option *ngFor="let data of dataset;let idx = index;" value= {{dataset[idx].serviceType}} >
{{dataset[idx].serviceType}}
</option>
</select>
</td>
<td>
<select placeholder="select a value" [(ngModel)]="data2" >
<option *ngFor="let data of data2.serviceValues;let idx = index" value= {{data}} >
{{data}}
</option>
</select>
</td>
But the error says : Cannot read property 'serviceValues' of undefined at Object.eval I am not able to find why it not able to read service values from the array.
Thanks