I am new in angular js, I want to display json data in tabular format, I have such Json as below
{
"cars": [{
"name": "Ford",
"models": [{
"state": "MH",
"model": "Fiesta"
},
{
"state": "BHR",
"model": "Focus"
},
{
"state": "DL",
"model": "Mustang"
}
]
},
{
"name": "BMW",
"models": [{
"state": "MH",
"model": "320"
},
{
"state": "BHR",
"model": "X3"
},
{
"state": "DL",
"model": "X5"
}
]
},
{
"name": "Fiat",
"models": [{
"state": "MH",
"model": "300"
},
{
"state": "BHR",
"model": "Panda"
},
{
"state": "DL",
"model": "Punto"
}
]
}
]
}
I want to use above JSON and display table in below format
and I have tried following angular js code
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.records = {
"name": "John",
"age": 30,
"cars": [
{
"name": "Ford",
"models": [
{
"state": "MH",
"model": "Fiesta"
},
{
"state": "BHR",
"model": "Focus"
},
{
"state": "DL",
"model": "Mustang"
}
]
},
{
"name": "BMW",
"models": [
{
"state": "MH",
"model": "320"
},
{
"state": "BHR",
"model": "X3"
},
{
"state": "DL",
"model": "X5"
}
]
},
{
"name": "Fiat",
"models": [
{
"state": "MH",
"model": "300"
},
{
"state": "BHR",
"model": "Panda"
},
{
"state": "DL",
"model": "Punto"
}
]
}
]
}
});
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body ng-app="myApp" ng-controller="myCtrl">
<table border=1>
<tbody ng-repeat="row in records.cars">
<tr>
<th>State</th>
<th>{{row.name}}</th>
</tr>
<tr ng-repeat="sub in row.models">
<td>{{sub.state}}</td>
<td>{{sub.model}}</td>
</tr>
</tbody>
</table>
</body>
</html>
but after running above code I am getting below result,
what is the way to solve this issue ?