我正在调用我的Parse Server&使用Parse Javascript API将数据下拉到我的Angular V1(是JS或IO ?!)应用程序中。我的通话功能如下:
$scope.getInventoryItems = function () {
var query = new Parse.Query("Inventory");
query.include("product");
query.include("retailer");
query.find({
success: function (results) {
$scope.inventoryItems = [];
for (i = 0; i < results.length; i++) {
var p = results[i].get("product");
var r = results[i].get("retailer");
var inventoryItem = {
objectId: results[i].id,
productObjectId: p.id,
barcode: p.get("barcode"),
productName: p.get("name"),
imageUrl: p.get("image"),
Qty: results[i].get("QTY"),
newQty: results[i].get("QTY"),
shoppingQty: 1,
retailerImage: r.get.Logo("url"),
retailerName: r.get("Name")
}
console.log(inventoryItem);
$scope.inventoryItems[$scope.inventoryItems.length] = inventoryItem;
}
$scope.$apply();
},
error: function (error) {
console.log("Query Error: " + error.message);
}
})
}
继承人JSON服务器响应:
{
"results": [{
"objectId": "Fo02snRmlP",
"product": {
"objectId": "eCA7BwB7kF",
"barcode": 54775912,
"name": "Extra Peppermint Gum 5 Pack",
"image": "[image url removed]",
"createdAt": "2017-11-22T01:28:16.605Z",
"updatedAt": "2017-11-22T01:28:16.605Z",
"__type": "Object",
"className": "Products"
},
"QTY": 4,
"createdAt": "2017-11-22T01:28:16.859Z",
"updatedAt": "2017-11-22T01:28:16.859Z",
"ACL": {
"NV6ubzeAHL": {
"read": true,
"write": true
}
"retailer": {
"objectId": "u2qNoKDAWV",
"Name": "My Supermarket",
"createdAt": "2017-09-20T17:16:48.151Z",
"updatedAt": "2017-11-13T19:40:26.371Z",
"Logo": {
"__type": "File",
"name": "c600325c63f7fb252b36c08c8c6168ab_supermarket_logo_full.svg",
"url": "https://my-api.herokuapp.com//files/my-api/c600325c63f7fb252b36c08c8c6168ab_supermarket_logo_full.svg"
},
"shortName": "supermarket",
"__type": "Object",
"className": "Retailers"
},
}
}, {
除了我尝试使用retailerImage: r.get.Logo("url")
收集的徽标网址外,一切都很成功。我如何获得这个双嵌套项?
由于
答案 0 :(得分:2)
Logo
是retailer
的另一个属性,对吧?您似乎只需要使用r.get('Logo').url()
var profilePhoto = profile.get("photoFile");
$("profileImg")[0].src = profilePhoto.url();