Change @Input handling.

This commit is contained in:
Alexis Lahouze 2018-06-14 21:48:34 +02:00
parent 8eaa3b9039
commit 8b63a9d5df

View File

@ -2,11 +2,7 @@
import * as moment from 'moment';
import {
Component, ViewChild,
Inject, Input, Output, EventEmitter,
OnInit, OnChanges
} from '@angular/core';
import { Component, ViewChild, Input, OnInit } from '@angular/core';
import { ActivatedRoute, Router, ParamMap } from '@angular/router';
import { Logger } from '@nsalaun/ng-logger';
@ -32,8 +28,8 @@ import { DailyBalanceService } from '../accounts/dailyBalance.service';
</jqxChart>
`
})
export class BalanceChartComponent implements OnInit, OnChanges {
@Input() account: Account;
export class BalanceChartComponent implements OnInit {
private _account: Account;
@ViewChild('balanceChart') chart: jqxChartComponent;
public data;
@ -168,10 +164,15 @@ export class BalanceChartComponent implements OnInit, OnChanges {
this.loadData();
}
ngOnChanges(changes) {
if('account' in changes && changes.account.currentValue) {
this.setLines(changes.account.currentValue);
@Input()
set account(account: Account) {
this._account = account;
this.setLines(account);
}
get account(): Account {
return this._account;
}
updateXBands(minDate, maxDate) {