我有以下界面:
export interface IdataTypes {
dataType: {
Categories: string[],
isSelected: boolean,
}
}
和以下JSON
{
"Sensitive Personal Data": {
"isSelected": "false",
"legalReference": "",
"Categories": [
"Health Data",
"Genetic Data",
"Biometric Data",
"Trade Union Data",
"Religious Data",
"Political Opinion",
"Philosophical Belief",
"Racial or Ethic Origin",
"Sex Life",
"Sexual Orientation"
]
},
"Personal Data with Higher Risk":{
"isSelected":"false",
"legalReference":"",
"Categories":["location","Financial/Social Status","Data Related to Profiling",
"video surveillance","data on adoption and custody"]
}
}
我想读取文件的“ dataTypeCategories” 并将其分配给Interface文件的变量。所以我要做以下
for(let i=0; i<response["Personal Data with Higher Risk"].Categories.length;i++){
this.dataTypeHighRisk["Personal Data with Higher Risk"][i].Categories.push
(response["Personal Data with Higher Risk"].Categories[i]);
this.dataTypeHighRisk["Personal Data with Higher Risk"][i].isSelected=false;
;
}
我收到此错误:core.js:1542错误错误:未捕获(承诺):ReferenceError:未定义类别
您能建议我如何做吗?我对javascript和angular都是陌生的。
更新,该数组定义为:dataTypeHighRisk:IdataTypes [] = []; 我不知道如何定义具有高风险的财产“个人数据/