Upgrade routing to Angular2.

This commit is contained in:
Alexis Lahouze
2017-08-01 23:09:21 +02:00
parent 2ae8a9cfad
commit 5726d8bf2e
13 changed files with 81 additions and 59 deletions

View File

@ -1,5 +1,7 @@
// vim: set tw=80 ts=2 sw=2 sts=2 :
import { Component, Inject, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Rx';
import { Logger } from '@nsalaun/ng-logger';
@ -71,16 +73,18 @@ export class OperationListComponent implements OnInit {
private operations: Operation[];
constructor(
@Inject("accountIdService") private accountIdService,
private toastrService: ToastrService,
private operationService: OperationService,
private accountService: AccountService,
private logger: Logger,
private ngbModal: NgbModal,
private route: ActivatedRoute
) {}
ngOnInit() {
this.accountService.get(this.accountIdService.get()).subscribe(account => {
this.accountService.get(
+this.route.snapshot.paramMap.get('accountId')
).subscribe(account => {
this.account = account
});
}
@ -90,7 +94,7 @@ export class OperationListComponent implements OnInit {
*/
add() {
var operation = new Operation();
operation.account_id = this.accountIdService.get();
operation.account_id = this.account.id;
// FIXME Alexis Lahouze 2017-06-15 i18n
const modal = this.ngbModal.open(OperationEditModalComponent);
@ -111,7 +115,7 @@ export class OperationListComponent implements OnInit {
this.maxDate = maxDate;
return this.operationService.query(
this.accountIdService.get(),
this.account.id,
minDate,
maxDate
).subscribe((operations: Operation[]) => {