1π
β
In my controller, I processed through the response to create the arrays for the chart.
angular.module('MyApp').controller("Ctrl", ["$scope", "FactoryGettingDataFromFirebase",
function($scope, FactoryGettingDataFromFirebase) {
var Status = {};
var Results = FactoryGettingDataFromFirebase;
Results.$loaded().then(function() { // Wait for Promise from Firebase
angular.forEach(Results, function(ResultInfo) {
Status[ResultInfo.Status] += 1; // Increment Each Status as it is found
});
});
}
$scope.StatusCounts = Status;
]);
You could also have a factory to clear and initialize the Status data first with all your values to make them 0 counts.
angular.module('MyApp').factory("ClearStatus", function() {
return function(StatusArray) {
StatusArray['Referred'] = 0;
StatusArray['Completion'] = 0;
...
};
});
Source:stackexchange.com