1
我能夠從DynamoDB收集數據,但是我嘗試使用AngularJS服務將數據傳遞給控制器時未定義TypeError。讓AngularJS與AWS DynamoDB合作
// Query for Replicated Site Using Name
coachdb.query(param, function(err,data) {
if (err) {
console.log(err, err.stack); // an error occurred
} else {
if (data.Items.length > 0) {
//console.log(data); // THIS IS LOGGING DATA
var x = (data);
var y = x.Items[0];
console.log(x.Items[0]); // THIS LOGS DATA
console.log(y); // THIS LOGS THE SAME DATA
this.coach = function() {
return y; // THIS SEEMS TO BE WHERE MY ERROR IS COMMING FROM.
}
if ("firstName" in x.Items[0]) {
var firstName = x.Items[0].firstName.S;
alert(firstName); // THIS PRODUCES AN ALERT THAT WORKS
}
}
}
});
我也可以手動創建一個對象,這與我從DynamoDB中提取的功能相當,而且工作得很好。
var nestObject = {
"company": { "S" : "ACME"},
"email" : {"S" : "[email protected]"},
"firstName" : {"S" : "Jared"},
"lastName" : {"S" : "Whipple"},
"phone" : {"S" : "435.494.3333"},
"repNum" : {"N" : 12164}
};
this.coach = function() {
return nestObject;
}
我怎樣才能從DynamoDB數據傳遞 表名:ximoRepList
這與dynamodb或couchdb有什麼關係?什麼是coachdb? – TimoSolo 2016-09-09 13:41:01
不,這只是一個嚴重的命名參數 – 2016-09-11 00:24:23