Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Injectable } from '@angular/core';
import { SessionStorageService } from 'ngx-webstorage';
@Injectable()
export class StateStorageService {
constructor(
private $sessionStorage: SessionStorageService
) {}
getPreviousState() {
return this.$sessionStorage.retrieve('previousState');
}
resetPreviousState() {
this.$sessionStorage.clear('previousState');
}
storePreviousState(previousStateName, previousStateParams) {
const previousState = { 'name': previousStateName, 'params': previousStateParams };
this.$sessionStorage.store('previousState', previousState);
}
getDestinationState() {
return this.$sessionStorage.retrieve('destinationState');
}
storeUrl(url: string) {
this.$sessionStorage.store('previousUrl', url);
}
getUrl() {
return this.$sessionStorage.retrieve('previousUrl');
}
storeDestinationState(destinationState, destinationStateParams, fromState) {
const destinationInfo = {
'destination': {
'name': destinationState.name,
'data': destinationState.data,
},
'params': destinationStateParams,
'from': {
'name': fromState.name,
}
};
this.$sessionStorage.store('destinationState', destinationInfo);
}
}