diff --git a/src/operations/category-chart.component.ts b/src/operations/category-chart.component.ts index f07bec8..a90c637 100644 --- a/src/operations/category-chart.component.ts +++ b/src/operations/category-chart.component.ts @@ -33,17 +33,18 @@ module.exports = angular.module('categoryChartModule', [ template: '
', bindings: { minDate: '<', - maxDate: '<' + maxDate: '<', + account: '<' }, - controller: function(accountIdService, $element, Categories, Incomes) { + controller: function($element, Categories, Incomes) { var vm = this; - vm.loadData = function() { - Categories.query({ - id: accountIdService.get(), - begin: vm.minDate ? moment(vm.minDate).format('YYYY-MM-DD') : null, - end: vm.maxDate ? moment(vm.maxDate).format('YYYY-MM-DD') : null - }, function(results) { + vm.loadData = function(account: Account) { + categoryService.query( + accountIdService.get(), + vm.minDate ? moment(vm.minDate).format('YYYY-MM-DD') : null, + vm.maxDate ? moment(vm.maxDate).format('YYYY-MM-DD') : null + ).subscribe((results) => { var expenses=[], revenues=[], colors={}, @@ -107,14 +108,13 @@ module.exports = angular.module('categoryChartModule', [ show: false } }); - - //vm.loadData(); }; - vm.$onChanges = function() { - vm.loadData(); + vm.$onChanges = function(changes) { + if('account' in changes && changes.account.currentValue) { + vm.loadData(changes.account.currentValue); + } }; - } }) diff --git a/src/operations/operations.html b/src/operations/operations.html index a53afa7..0fca7d7 100644 --- a/src/operations/operations.html +++ b/src/operations/operations.html @@ -24,7 +24,8 @@
+ max-date="operationsCtrl.maxDate" + account="operationsCtrl.account"/>