我将对象存储在previousState
和currentState
的会话存储中,但刷新会使previousState消失。我正在$transitions.onSuccess
更新两者。看起来transition.from()
属性会丢失。
$transitions.onSuccess({}, function(transition) {
var tempTransitionFrom = transition.from();
var tempTransitionTo = transition.to();
appState.update('previousState', tempTransitionFrom.name);
appState.update('currentState', tempTransitionTo.name);
});
这是我的appState.update函数
service.update = function(propertyName, property) {
service.data[propertyName] = property;
$window.sessionStorage["appState"] = JSON.stringify(service.data);
};
currentState
很好,因为它留在那里,但我该怎么办才能让previousState
不再消失?