有没有办法用对象键动态地从对象列表中读取对象。 我的复杂对象类似于:
$scope.mainObject = {
name : "Some value",
desc : "Some desc",
key1: {
arrayLst: []
},
key2: {
arrayLst: []
}
}
在我的方法中,我在字符串key1
中的键值为key2
或keyValue
。我怎样才能写对象:
$scope.mainObject.key1.arrayLst = data;
以类似的形式出现:
$scope.mainObject.get(keyValue).arrayLst = data;
答案 0 :(得分:1)