how to received a data from post array in angular JS into Codeigniter ?, below is my code
controller in Codeigniter
public function add_data_chat()
{
$datas = json_decode(file_get_contents('php://input'), TRUE);
$message = $datas ["message"];
$payment_step = $datas ["payment_step"];
$negotiation_price = $datas ["negotiation_price"];
$room_id = $datas["room_id"];
$member_id = $datas["member_id"];
$sql="INSERT INTO dash_chat_documentation (message, payment_step, negotiation_price, room_id, member_id, chat_time) VALUE ('$message','$payment_step',$negotiation_price,'$room_id',$member_id,now())";
$data= $this->db->query($sql);
}
ANGULARjs
$scope.tambahData = function(){
databaru = {
message:$scope.databaru.message,
payment_step:'regular_chat',
negotiation_price:'0',
room_id:'123',
member_id:'01'
};
$http({
method: 'POST',
url: '<?php echo base_url('dashboard/workspace/add_data_chat') ?>',
headers : {'Content-Type': 'application/x-www-form-urlencoded'},
data: $scope.databaru
}).success(function (hasil) { $scope.data.push({
message: $scope.databaru.message,
chat_time: $scope.databaru.chat_time
});
$scope.databaru.message='';
});
};
the problem why i cannot received a data from angularJS to codeigniter, please help