Use Account Id service instead of $stateParam.

This commit is contained in:
Alexis Lahouze 2017-07-29 22:53:41 +02:00
parent 0a5a7e72e3
commit bb21dd700e

View File

@ -9,7 +9,8 @@ import { Operation } from './operation';
import { OperationService } from './operation.service'; import { OperationService } from './operation.service';
module.exports = function( module.exports = function(
$stateParams, $modal, $modal,
accountIdService,
toastrService: ToastrService, toastrService: ToastrService,
operationService: OperationService, operationService: OperationService,
AccountService AccountService
@ -21,7 +22,7 @@ module.exports = function(
*/ */
vm.add = function() { vm.add = function() {
var operation = new Operation(); var operation = new Operation();
operation.account_id = $stateParams.accountId; operation.account_id = accountIdService.get();
return vm.modify(operation); return vm.modify(operation);
}; };
@ -34,7 +35,7 @@ module.exports = function(
vm.maxDate = maxDate; vm.maxDate = maxDate;
return operationService.query( return operationService.query(
$stateParams.accountId, accountIdService.get(),
minDate, minDate,
maxDate maxDate
).subscribe((operations: Operation[]) => { ).subscribe((operations: Operation[]) => {
@ -162,7 +163,7 @@ module.exports = function(
vm.load(dateRange.minDate, dateRange.maxDate); vm.load(dateRange.minDate, dateRange.maxDate);
}; };
AccountService.get($stateParams.accountId).subscribe(account => { AccountService.get(accountIdService.get()).subscribe(account => {
vm.account = account vm.account = account
}); });
}; };