i am trying to get data from php server using angularjs http i user codeigniter as server side here is my codeigniter controller
public function searchuser() {
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$this->load->model('user_model');
$data["users"] = $this->user_model->getuserpro($request->email);
print_r($data);
}
here is my codeigniter model
`function getuserpro($uid) {
$query = $this->db->get_where("user", array("email" => $uid));
return $query->result();
}`
here is my angular controller
`angular.module('starter').controller('profileCtrl', function($scope, $state, userlog, $http) {
var request = $http({
method: "post",
url: "http://mydomain/Home/searchuser",
data: {
email: userlog.email,
},
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
});
/* Check whether the HTTP Request is successful or not. */
request.success(function(data) {
document.getElementById("namemy").textContent = data;
console.log(data);
});
});
` when i log data it's like this
"Array
(
[users] => Array
(
[0] => stdClass Object
(
[iduser] => 171
[email] => chhdshfh@gmail.com
[password] => 123
[fname] => cha
[lname] => shm
[dbth] => 1989-08-19 00:00:00
[addone] => aaaaaaaa
[addtwo] => cccccccccccc
[city] => bbbbbbbbbbbbb
[country] => LK
[tp] => 0111111111
[currency] => LKR
[gender] => A
[job] => sdfsdf
)
)
)
"
how can i split this array and assign value to separate variable like id,email,password,fname,lname i tried like this
` $scope.id=data.iduser;
$scope.email=data.email;
$scope.pass=data.password;
$scope.fname=data.fname;
$scope.lname=data.lname;`
that's not working please any one help