我正在使用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休息控制器?
如果您需要任何其他信息,請讓我知道,我會提供。先謝謝你!