1

我已经习惯了 AngularJS ng-resource 但我在序列化数组时遇到了问题。我的 ng-resource 是这样的

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

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

}]);

我的控制器看起来像这样:

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

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

                });
});

问题是它通过了这样的条件:

conditions:{"join":"table2"}

它将作为必须解码的字符串传递给 php。我的问题是如何将条件作为 php 的关联数组传递?

4

2 回答 2

1

将此附加到您的 get 请求和 var dump $_GET。

?条件[加入]=table2

于 2013-11-24T10:37:27.150 回答
0

您的参数需要是一个数组,而不是一个对象:

...
conditions: ['join', 'table2']
...
于 2013-11-23T23:06:31.723 回答