I have the following JavaScript object which I need to apply parseFloat to any number value field (in order for ngTable to sort correctly).
I'm having a tough time looping through the Object to do this. I've tried a nested angular.forEach
, but I have scoping issues (inner loops don't see outer variables).
What's the best manner to approach this?
The Object names (i.e: Person and PersonDetails) are dynamic. :/
My object:
{
"data": [
{
"Person": {
"id" : "1",
"age": "23",
"days": "5",
"first_name": "Joe",
"last_name": "Smith",
},
"PersonDetails": {
"id": "4",
"name": "Cousin",
"oldest: "2",
}
},
{
"Person": {
"id" : "2",
"age": "18",
"days": "3",
"first_name": "John",
"last_name": "Doe",
},
"PersonDetails": {
"id": "4",
"name": "Second Cousin",
"oldest: "3",
}
}
...
...
]
};