This question already has an answer here:
- How to do ngFor loop on nested json object? 4 answers
I am new angular 2. I am able to get Json file. I am able to get some part json file but not the array inside json file. For example I want to visualise GPS device in First UL and IMU device in second UL. SInce they are array I am getting same data of IMU device in bOTH the lists.
json file
"config" : [
{
"id" : "gps_device",
"name" : "GPS Device",
"type" : "String",
"widget" : "dropdown",
"fields" : [ "Disabled", "XSensIMU", "GenesysADMA"],
"default" : "Disabled"
},
{
"id" : "imu_device",
"name" : "IMU Device",
"type" : "String",
"widget" : "dropdown",
"fields" : [ "Disabled1", "XSensIMU1", "GenesysADMA1"],
"default" : "XSensIMU"
}
]
//here I should get loop of GPS device array
<h1>Gps Device</h1>
<ul *ngFor="let drop of config[0]">
<li *ngFor="let sub of drop.fields"> {{sub}}</li>
<ul>
//here array of IMU device
<h1>IMU Device</h1>
<ul *ngFOr="let drop1 of config[1]">
<li *ngFOr="let sub1 of drop.fields"> {{sub1}}</li>
<ul>