I have an HTTP request in Angular that pulls all data from a Mysql table.
$http({
method: "POST",
url: "framework/actions/league.php?query=getDivision"
}).success(function(data){
$scope.division = data;
});
A snippet of the data looks like this:
[
{
name: "Someone",
number: "4",
game1: "6",
game2: "2",
score: "8"
},
{
name: "Someone else",
number: "7",
game1: "7",
game2: "3",
score: "10"
},
]
When that data comes back from the HTTP request and gets assigned to $scope.division
, the numbers are treated as strings, which gives me problems when using orderBy
in an ngRepeat
.
How can I get number fields to be treated as numbers without having to declare each field in a forEach
and use parseInt()
? Is it possible to do this in the PHP? If not, doing it in the Angular javascript would be fine.
Of course I can't treat every field as a number because of the name field.