-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,633
  • 7
  • 33
  • 60
Debojyoti
  • 169
  • 1
  • 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,478
  • 3
  • 36
  • 40
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
  • 494
  • 5
  • 14