Fix component initialization.
This commit is contained in:
parent
0e001cf680
commit
1859efb98c
@ -3,7 +3,7 @@
|
|||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router, Params } from '@angular/router';
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
|
|
||||||
@ -80,31 +80,28 @@ export class OperationListComponent implements OnInit {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.queryParamMap.subscribe(() => {
|
this.route.queryParamMap.subscribe((params: Params) => {
|
||||||
this.loadData();
|
if (params.get('from') && params.get('to')) {
|
||||||
});
|
|
||||||
|
|
||||||
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) {
|
|
||||||
this.router.navigate([], {
|
|
||||||
queryParams: {
|
|
||||||
from: moment().startOf('month').format('YYYY-MM-DD'),
|
|
||||||
to: moment().endOf('month').format('YYYY-MM-DD')
|
|
||||||
}
|
|
||||||
}).then(() => {
|
|
||||||
this.loadData();
|
this.loadData();
|
||||||
});
|
} else {
|
||||||
}
|
this.router.navigate([], {
|
||||||
|
queryParams: {
|
||||||
this.accountService.get(
|
from: moment().startOf('month').format('YYYY-MM-DD'),
|
||||||
+accountId
|
to: moment().endOf('month').format('YYYY-MM-DD')
|
||||||
).subscribe(account => {
|
}
|
||||||
this.account = account;
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.route.paramMap.subscribe((params: Params) => {
|
||||||
|
let accountId = params.get('accountId');
|
||||||
|
|
||||||
|
this.accountService.get(
|
||||||
|
+accountId
|
||||||
|
).subscribe(account => {
|
||||||
|
this.account = account;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
//this.loadData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user