angularjs - How to Post the values of dynamically added field in angular js to php? -


i have form dynamically fields added.

$scope.choices = [{id: 'choice1'}]; $scope.removechoice = function(z)       {         var lastitem = $scope.choices.length-1;         $scope.choices.splice(z,1);     };      $scope.addnewchoice = function()      {         var newitemno = $scope.choices.length+1;         $scope.choices.push({'id':'choice'+newitemno});       }; 

the values inserted correctly in controller file when insert function called. inser function follows.

$scope.insert = function()         {              $scope.checklist_name = $scope.values.checklist_name;             $scope.data =[];             $scope.data = $scope.choices;              //alert('companyid=='+$scope.app.company_id);              $scope.item = [];             var newitem = {};              for( var in $scope.choices)             {                 newitem= $scope.choices[i];                 $scope.item.push(newitem);             }              console.log( "item",$scope.item);              var fd = new formdata();                fd.append('action', app_action.insert_checklist);             fd.append('company_id', $scope.app.company_id);             fd.append('user_id', $cookiestore.get('userdata').id);             fd.append('checklistname',$scope.checklist_name);             fd.append('checklistdata',$scope.item);              httpcall.remotecallpost($scope, $http, fd, function (record)              {                 alert('data========'+record.data);              }, function (message)              {                 alert('error');             });         } 

the data in $scope.item

[ 0:{id: "choice1", number: "1", shortext: "1", longtext: "1", photo: true},     1:{id: "choice2", number: "2", shortext: "2", longtext: "2"},     2:{id: "choice3", number: "3", shortext: "3", longtext: "3"} ] 

and when receive request in php backend got array

array (     [action] => insertchecklist     [company_id] => 2     [user_id] => 13     [checklistname] => sadasdsa     [checklistdata] => [object object],[object object],[object object] ) 

my question how access datas coming object or sendind data in wrong way , if sending them in wrong way how send data in correct proper way ?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -