0
我正在使用ng-storage來存儲JSON,以便在刷新的情況下跟蹤選中的複選框和各種表單值(大量表單)。有在本地存儲已滿,並重新加載頁面的結果在一定的情景:檢測完整的HTML5存儲(ng-storage)
壞郵件431原因:請求頭字段太大
我發現沒有辦法來捕獲和處理這個響應在這種情況下清除我的存儲。如果有幫助,這是我的服務:
angular.module('app')
.service('CookieService', function($localStorage, SharedService) {
$localStorage[SharedService.activeOffer.id] = $localStorage[SharedService.activeOffer.id] || {};
var localStorage = $localStorage[SharedService.activeOffer.id];
return {
localStorage: localStorage,
setSession: function(id, data) {
checkLocalStorageUsage();
if (typeof data != "string") {
data = JSON.stringify(data);
}
localStorage[id] = data;
},
getSession: function(id) {
if (localStorage[id]) {
return JSON.parse(localStorage[id]);
}
},
checkSession: function(id) {
return (!!(localStorage[id] && localStorage[id].length));
},
removeSession: function(id) {
delete localStorage[id];
},
removeAllSessions: function(id) {
$localStorage.$reset();
}
};
});