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