K
K
Karina2015-08-31 00:09:15
symfony
Karina, 2015-08-31 00:09:15

How to get from symfony2 in angular?

Hello.
I usually receive data:

$em = $this->getDoctrine()->getManager();
$result = $em->getRepository('CustomEmployeeBundle:Employee')->findByLastName($last_name);

I output the $result variable with var_dump - that's what I need.
I also send, like, usually:
return new Response(json_encode($result), 200);
But when I go to the right address, I see empty brackets there.
Angular has a simple function:
$http.get("/employee/search/"+$scope.last_name).success(function (data) {
        $scope.results = data;
        console.log($scope.results);
      });

But there is some nonsense in $scope.results. Everything, like, checked - there are no values ​​there.
fc467786f66645099480ddd616217ecc.png
Thanks everyone for the replies.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wittyrider, 2015-08-31
@iKapex

return new Response(json_encode($result), 200);

json_encode does not serialize the object. use serializer service

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question