1
我在AngularJS中使用ngStorage
在localStorage
中保存了幾個項目,但如果用戶的localStorage
已滿,我如何捕獲該錯誤並允許JavaScript繼續運行?在angularjs中,當localStorage已滿時,你如何捕獲ngStorage的錯誤?
try {
$scope.$storage.gridObject = $scope.gridConfig.data;
$scope.$storage.dataStored=true;
}
catch(err) {
//failed to save to local storage, try clearing localStorage for IAP and throw error
$scope.$storage.dataStored=false;
$scope.$storage.$reset({
dataStored: false,
gridObject: {}
})
console.log('error occured message');
}