I am trying to store data in an array to the $http
service in AngularJS. The way I am currently adding them to the service is as follows (and it is functioning correctly):
var inputValueArray = new Array($scope.formdata);
Currently, I am able to retrieve data using index zero in my API. However, I want to be able to retrieve data using a named index. So, I tried the following:
var inputValueArray = new Array();
inputValueArray["myIndex"] = $scope.formData;
Unfortunately, when I try to retrieve data in the API, I get an empty array. I then attempted the following solution:
var inputValueArray = {"myIndex" : $scope.formData};
Now, I am encountering a Maximum call stack size exceeded
error. In both cases, I am using $_POST
to receive the data. I am sending the data using $.param() like this:
data: $.param({ mydata:inputValueArray , csrf_token: myTokenKey})
Any suggestions or ideas would be greatly appreciated.