我正在保存几个项目以在 AngularJS 中使用,但如果用户localStorage
已满,我如何才能捕捉到该错误并允许 JavaScript 继续运行?ngStorage
localStorage
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');
}