I have this list with a key,value structure that stores the data coming from a JSON structure and I want to print this data in a table with an ng-repeat.
var data = [
{
id: 1,
name : "Peter",
lastname : "Smith",
age : 36
}, {
id: 2,
name : "Peter",
lastname : "Smith",
age : 36
}
];
$scope.itemDictionary = {};
angular.forEach(data, function(item){
var obj = {};
var valObj = {};
valObj.name = item.name;
valObj.lastname = item.lastname;
valObj.age = item.age;
obj[item.id] = valObj;
if(!$scope.itemDictionary[item.id]){
$scope.itemDictionary[item.id] = obj;
}
});
I know that it should be ng-repeat="d in something" inside a table but I dont know how to achive this based on the structure that I have.