2
多個對象我在下面格式JSON對象,存儲使用HTML5 INDEXDB
$scope.indexData = {
"custid": "1",
"addresses": [
{
"addressType": "P",
"address1": ""
},
{
"addressType": "M"
}
],
"personalDetails": {
"title": "",
"name": ""
}
}
我想存儲使用HTML5 INDEXDB的對象。我如何存儲對象?
我嘗試了以下方法,但沒有運氣。
var db;
var request = window.indexedDB.open("newDatabase", 1);
request.onupgradeneeded = function(event) {
var db = event.target.result;
var objectStore = db.createObjectStore("customers");
for (var i in $scope.indexData) {
objectStore.add($scope.indexData[i]);
}
}
我收到以下錯誤說:Uncaught DataError: Failed to execute 'add' on 'IDBObjectStore': The object store uses out-of-line keys and has no key generator and the key parameter was not provided.
感謝#Vino..its工作正常 – vishnu