duanchu9914 2015-10-08 12:32
浏览 75

无法使用AngularJS从Symfony控制器打印json数据

I am building a simple app here in order to get some json response from a sqlite database and manipulate the data with Angular. Although i send the response from Symfony i cannot use ng-repeat in Angular . Is there any error in the serialization from Symfony? The delimiter for Angular is [[ ]]

My Symfony Controller acts as an api

class UserController extends Controller
{
    /**
     * @Route("/users", name="get_users")
     */
    public function indexAction(Request $request)
    {
        $users = $this->getDoctrine()
            ->getRepository('AppBundle:Data')
            ->findAll();
            // $serializedUsers = $this->container->get('serializer')->serialize($users, 'json');
            $serializer = $this->get('serializer');
            $array = $serializer->normalize($users);
        return new JsonResponse($array);
    }

My angular controller

userApp.controller('UserController',function($scope,$http){
    $http.get('/users').success(function(response){
        $scope.users = response;

    });
});

My html view

<div ng-repeat="user in users">
                [[user.id]]
            </div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码