I have an Array which i need to convert it into Table format to be displayed in HTML.
<table>
<tr>
<th ng-repeat='(key, value) in data[0]'>{{key}}</th>
</tr>
<tr ng-repeat="(key,value) in data">
<td ng-repeat="item in data[key]" ng-if="$index!=0">{{item}}</td>
</tr>
</table>
var data = [{
"recordno": "001",
"firstname": "Brock",
"middlename": "Edward",
"lastname": "Lesnar",
"gender": "male",
"dateofbirth": "1980-01-01T20:20:19.198Z",
"dateofdeath": null,
"status": "archive"
}, {
"recordno": "002",
"firstname": "John",
"middlename": "E",
"lastname": "Cena",
"gender": "male",
"dateofbirth": "1980-01-01T20:20:19.198Z",
"dateofdeath": null,
"status": "archive"
}];
function TableController($scope) {
$scope.data = data;
}
I am facing with 2 issues :-
- Array in table automatically gets sorted. I want to display records as they are in Array.
- I want to show
Statusvalues to be shown asbutton& when clicked on btn it callsng-click.
What is the right way to do this?
Is there any other way to do this. Because Array is Dynamically passed.