Inject account in category chart component instead of using accountIdService.
This commit is contained in:
parent
fa147e74fc
commit
2812891b23
@ -33,17 +33,18 @@ module.exports = angular.module('categoryChartModule', [
|
||||
template: '<div></div>',
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -24,7 +24,8 @@
|
||||
<div class="col-md-3">
|
||||
<category-chart
|
||||
min-date="operationsCtrl.minDate"
|
||||
max-date="operationsCtrl.maxDate"/>
|
||||
max-date="operationsCtrl.maxDate"
|
||||
account="operationsCtrl.account"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user