我正在使用AngularJs(1.5)和Codeigniter rest服务器处理一个项目。我想知道为什么数据idTag不传递给PHP?让我告诉你我的代码,并进一步解释评论。数据不传递给api调用
我有这样的工厂
factory.get = function(idLocation, idTag){
console.log(idLocation, idTag); //Console log outputs 1 6, so data is here
return $http({
method: 'GET',
url: $location.protocol() + '://' + $location.host() + '/rest/api/locationtag/locationtag/' + idLocation,
data: {
idTag: idTag
}
}).then(function successCallback(response){
console.log(response);
// response is empty, because data isn't sent to PHP
return response.data;
},function errorCallback(response){
console.log('Error getting slide shows: ' + response.data.message);
});
};
这是我的PHP在那里我尝试获取代码
public function locationtag_get($idLocation)
{
$condition['id_location'] = $idLocation;
$condition['id_tag'] = $this->get('idTag');
var_dump($condition);
die();
$locationTag = $this->locations_tags->get($condition);
if ($locationTag) {
$this->response($locationTag, REST_Controller::HTTP_OK);
}
}
出放的var_dump是
'id_location' '1'
'id_tag' null
所以这个问题,为什么或如何正确地从GET方法发送数据到Codeigniter中的PHP休息控制器?
如果您需要任何其他信息,请让我知道,我会提供。先谢谢你!