down2323 2013-11-23 22:57
浏览 72
已采纳

AngularJS将对象作为PHP的数组发送

I'm getting use to AngularJS ng-resource but I am having a problem serieliazing an array. My ng-resource is like this

app.factory('MyModel', ['$resource', 'api_domain',
function($resource, api_domain) {

        return $resource(api_domain + 'adsizes/:id', {
            id : '@id'
        }, {
            get : {method: 'GET', isArray: true }
        })

}]);

And my controller looks like this:

    app.controller("MyCtrl", ['$scope', 'MyModel',
    function($scope, MyModel) {

        MyModel.get({
                    id : id,
                    'conditions': { 'join' : 'table2'}
                }, function() {

                });
});

The problem is it passes the conditions like so:

conditions:{"join":"table2"}

Which passes into php as a string that has to get decoded. My question is how can I pass the conditions as associative array for php?

  • 写回答

2条回答 默认 最新

  • dongyun65343 2013-11-24 10:37
    关注

    Append this to your get request and var dump $_GET.

    ?conditions[join]=table2

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图