$scope.objectData = {};
$scope.objectData[key]["digits"] = set.first+','+set.second+','+set.third+','+set.fourth;
此处键是一个数值。错误是
TypeError: Cannot set property 'digits' of undefined
答案 0 :(得分:1)
您需要先为对象设置$scope.objectData[key]
的值,然后才能为其添加更多键。
$scope.objectData[key] = {};
$scope.objectData[key]['digits'] = 'foo';
答案 1 :(得分:0)
首先必须初始化对象$scope.objectData[key]
,以便正确的代码为:
$scope.objectData = {};
$scope.objectData[key] = {};
$scope.objectData[key]["digits"] = set.first+','+set.second+','+set.third+','+set.fourth;