Skip to content

Instantly share code, notes, and snippets.

@dwelch2344
Created December 27, 2013 17:13
Show Gist options
  • Save dwelch2344/8149783 to your computer and use it in GitHub Desktop.
Save dwelch2344/8149783 to your computer and use it in GitHub Desktop.
angular.module('admin.stats', [])
.config(function($stateProvider) {
$stateProvider
.state('admin-stats', {
url: '/admin/stats',
templateUrl: 'admin/admin.stats/admin.stats.tpl.html',
controller: 'AdminStatController'
});
})
.controller('AdminStatController', function ($scope, $q, UserService, SaleService, EventService, Restangular) {
$scope.king = {};
var userAdmin = Restangular.all('users');
var eventAdmin = Restangular.all('admin/events');
var saleAdmin = Restangular.all('admin/sales');
var promises = [
userAdmin.getList(),
eventAdmin.getList(),
saleAdmin.getList()
];
$q.all(promises).then(function (results) {
var users = results[0],
events = results[1],
sales = results[2];
console.log("How'd we do?", users, events, sales);
$scope.king.userArray = users;
$scope.king.eventArray = events;
$scope.king.salesList = sales;
var totals = SaleService.adminTotal();
$scope.king.salesTotal = totals.booksAdmin;
// TODO - associate the data as needed
});
})
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment