我正在使用AngularJS ng-resource,但我遇到了一個數組混淆的問題。我的NG-資源是這樣AngularJS將對象作爲數組發送給PHP
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關聯數組?
難道你不只是用於該json_encode在PHP中,你可以不發比用GET或POST請求反正弦其他的什麼嗎? – adeneo
json_encode會使它成爲json字符串。 –
它會,我當然意味着json_decode,將字符串轉換爲對象或數組。 – adeneo