Simplify loading using parameter instead of injected account object.
This commit is contained in:
parent
f9d26ed888
commit
89c1c4f64c
@ -5,7 +5,7 @@ import * as moment from 'moment';
|
||||
import {
|
||||
Component,
|
||||
Inject, Input, Output, EventEmitter,
|
||||
OnChanges
|
||||
OnInit, OnChanges
|
||||
} from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
@ -36,7 +36,7 @@ class DateRange {
|
||||
</jqxChart>
|
||||
`
|
||||
})
|
||||
export class BalanceChartComponent implements OnChanges {
|
||||
export class BalanceChartComponent implements OnInit, OnChanges {
|
||||
@Input() account: Account;
|
||||
@Output() onUpdate: EventEmitter<DateRange> = new EventEmitter<DateRange>();
|
||||
|
||||
@ -133,9 +133,11 @@ export class BalanceChartComponent implements OnChanges {
|
||||
this.data = [];
|
||||
}
|
||||
|
||||
loadData(account: Account) {
|
||||
loadData() {
|
||||
let accountId = this.activatedRoute.snapshot.paramMap.get('accountId');
|
||||
|
||||
this.dailyBalanceService.query(
|
||||
account.id
|
||||
+accountId
|
||||
).subscribe((results) => {
|
||||
this.data = results;
|
||||
|
||||
@ -157,12 +159,13 @@ export class BalanceChartComponent implements OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.loadData();
|
||||
}
|
||||
|
||||
ngOnChanges(changes) {
|
||||
if('account' in changes && changes.account.currentValue) {
|
||||
this.loadData(changes.account.currentValue);
|
||||
this.setLines(changes.account.currentValue);
|
||||
} else {
|
||||
this.setLines(this.account);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user