I am fairly new to AngularJS and I am working a new project with Laravel 5 and AngularJS.
So basically, I am trying to update the standings depending on some filters.
Here is how I call my api:
$http.post('/api/standings', {
category: $scope.current_category.id,
division: $scope.current_division.id,
gender: $scope.current_gender.slice(0,1),
season: $scope.current_season.id
}).
success(function(data, status, headers, config) {
var standings_array = [];
var stats_array = [];
angular.forEach(data, function(value,key){
standings_array[key] = value[0];
stats_array[key] = value[1];
});
$scope.standings = standings_array;
$scope.team_stats = stats_array;
});
And this is how I return the array:
$teams_array[] = array($team,$stats);
return $teams_array
And my view:
<tr ng-repeat='team in standings'>
<td><% $index+1 %></td>
<td><% team.name %></td>
<td><% team_stats[$index].games_played %></td>
<td><% team_stats[$index].points %></td>
<td><% team_stats[$index].win_pct %></td>
</tr>
Everything is fine, except for the win_pct, as it's a model accessor:
public function getWinPctAttribute()
{
$pct = Utils::calculatePercentage($this->points,$this->games_played*3);
$pct = number_format($pct, 2);
return $pct;
}
But the win_pct is returning nothing... Is there a way for me to access that value?
Thanks, Ara