Fix component initialization.

This commit is contained in:
Alexis Lahouze 2018-06-14 11:34:04 +02:00
parent 0e001cf680
commit 1859efb98c

View File

@ -3,7 +3,7 @@
import * as moment from 'moment';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute, Router, Params } from '@angular/router';
import { Observable } from 'rxjs/Rx';
@ -80,31 +80,28 @@ export class OperationListComponent implements OnInit {
) {}
ngOnInit() {
this.route.queryParamMap.subscribe(() => {
this.route.queryParamMap.subscribe((params: Params) => {
if (params.get('from') && params.get('to')) {
this.loadData();
});
let accountId = this.route.snapshot.paramMap.get('accountId');
let fromDay = this.route.snapshot.queryParamMap.get('from');
let toDay = this.route.snapshot.queryParamMap.get('to');
if(! fromDay && ! toDay) {
} else {
this.router.navigate([], {
queryParams: {
from: moment().startOf('month').format('YYYY-MM-DD'),
to: moment().endOf('month').format('YYYY-MM-DD')
}
}).then(() => {
this.loadData();
});
}
});
this.route.paramMap.subscribe((params: Params) => {
let accountId = params.get('accountId');
this.accountService.get(
+accountId
).subscribe(account => {
this.account = account;
});
//this.loadData();
});
}
/*