【发布时间】:2015-08-27 19:58:15
【问题描述】:
我在 AngularJS 中使用 ngStorage 将几个项目保存到 localStorage,但如果用户的 localStorage 已满,我如何才能捕获该错误并允许 JavaScript 继续运行?
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');
}
【问题讨论】:
标签: javascript html angularjs local-storage ng-storage