ledgerrb/public/app/js/main/controllers/BalanceCtrl.js
2014-07-30 20:48:32 +02:00

26 lines
838 B
JavaScript

app.controller( 'BalanceCtrl',
[ '$scope', '$http',
function( $scope, $http ) {
var now = new Date();
$scope.xFunction = function() {
return function( d ) {
return d.account;
};
};
$scope.yFunction = function() {
return function( d ) {
return d.amount;
};
};
$scope.balance = { expenses: [],
income: [] };
$http.get( '/api/ledger/balance?period=' + now.getFullYear() + '-' + now.getMonth() + '&categories=Expenses' )
.then( function( response ) {
$scope.balance.expenses = response.data;
} );
$http.get( '/api/ledger/balance?period=' + now.getFullYear() + '-' + now.getMonth() + '&categories=Income' )
.then( function( response ) {
$scope.balance.income = response.data;
} );
}]);