I'm working with php Tonic and AngularJS. So I have angular that call a rest resource. The code of the rest is like this:
/**
* @method GET
*/
public function getData(){
$response = new Response();
$response->code = Response::OK;
$response->body = array("one","two");
return $response;
}
On backend, code return a Response object with an array in the body. From angular I use $resource service to call backend:
return {
getBackData : function(){
var call = $resource('/table_animation_back/comunication');
call.get(function(data){
console.log(data);
});
}
}
The result of console.log is this:
Resource {0: "A", 1: "r", 2: "r", 3: "a", 4: "y", $promise: d, $resolved: true}0: "A"1: "r"2: "r"3: "a"4: "y"$promise: d$resolved: true__proto__: Resource
I tried to use:
call.query(function(){...})
but Response in php is an object and not an array, so in this way I got a javascript error. I can't access to the array. Where wrong?