Add accountIdService to be able to correctly retrieve accountId in UiRouter transition.

This commit is contained in:
Alexis Lahouze 2017-07-25 08:53:08 +02:00
parent ad16b5a391
commit fa9402e25e
1 changed files with 21 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ToastrService } from 'ngx-toastr';
var ngStrap = require('angular-strap');
import uiRouter from '@uirouter/angularjs';
var schedulerTmpl = require('./scheduler.html');
@ -37,6 +38,7 @@ import { ScheduleComponent } from './schedule.component';
import { ScheduleService } from './schedule.service';
export default angular.module('accountant.scheduler', [
uiRouter,
ngStrap
])
.factory('toastrService', downgradeInjectable(ToastrService))
@ -45,6 +47,19 @@ export default angular.module('accountant.scheduler', [
.factory('logger', downgradeInjectable(Logger))
.factory('accountIdService', function() {
var accountId: null;
return {
get: () => {
return accountId;
},
set: (value) => {
accountId = value;
}
}
})
.factory('scheduleService', downgradeInjectable(ScheduleService))
.component('scheduleComponent', {
@ -57,4 +72,10 @@ export default angular.module('accountant.scheduler', [
controllerAs: 'schedulerCtrl'
})
.run(function($transitions, accountIdService) {
$transitions.onSuccess({}, (transition) => {
accountIdService.set(transition.params().accountId);
});
})
.name;