我有一个数组,可以访问要设法获取这些属性值的属性列表,但是,列表中有一个嵌套的对象“ Region ”,该对象具有特定的属性我想检索该值的“ regionName ”,请检查代码并上传图像以供参考。
我希望这有道理。预先谢谢你
export function CreateStores(xhttp: XMLHttpRequest, storeArray?: Array<PromotionClasses.Store>) {
while (STORE_TABLE.rows.length > 1) {
STORE_TABLE.deleteRow(1);
}
if (storeArray == undefined) {
//Convert the response into an array of objects
storeArray = JSON.parse(xhttp.responseText) as Array<any>;
}
CheckForDuplicateStores(storeArray);
//Get the current row length of the table so we know where to append to
let tableRowLength = STORE_TABLE.rows.length as number;
console.log("Store array is");
// console.log(storesInPromotionArray);
for (let i = 0; i < storeArray.length; i++) {
//A dictionary containing the key value pair of the stores properties
let tableData = {};
//Add the store's id to the storeArray
let store = new PromotionClasses.Store(storeArray[i]["StoreName"], storeArray[i]["id"]);
storesInPromotionArray.push(store);
console.log(storeArray[i]["region"]);
var check = storeArray[i]["region"];
//let attr = new PromotionClasses.Attribute(storeArray[i].name, storeArray[i].type, storeArray[i].property);
//Assingattributes.push(attr);
//Create and insert a new row
let row = STORE_TABLE.insertRow(tableRowLength);
//row.contentEditable = 'true'
//The first three cells will always be the row number, store number and name
tableData["#"] = i.toString();
tableData["Number"] = storeArray[i]["storeNumber"];
tableData["Name"] = storeArray[i]["storeName"];
tableData["addressLine"] = storeArray[i]["addressLine"];
tableData["postcode"] = storeArray[i]["postcode"];
//****NESTED OBJECT PROPERTY = regionName
tableData["region"] = storeArray[i]["region"];