-2
$scope.objectData = {};
$scope.objectData[key]["digits"] =  set.first+','+set.second+','+set.third+','+set.fourth;

here key is a numerical value.The error is

TypeError: Cannot set property 'digits' of undefined
Madhawa Priyashantha
  • 9,427
  • 7
  • 31
  • 59
Debojyoti
  • 169
  • 14

2 Answers2

1

You need to set the value of $scope.objectData[key] to an object before you can add more keys to it.

$scope.objectData[key] = {};
$scope.objectData[key]['digits'] = 'foo';
Ankh
  • 5,003
  • 3
  • 35
  • 37
0

You first have to initalize the object $scope.objectData[key] so the right code would be:

$scope.objectData = {};
$scope.objectData[key] = {};
$scope.objectData[key]["digits"] = set.first+','+set.second+','+set.third+','+set.fourth;
Nick Messing
  • 474
  • 5
  • 14