2014-05-11 8 views
0

백엔드에 필요한 페이로드 '{}'를 사용하여 게시물 요청을 보내려했습니다. angle의 $ resource 서비스를 사용하고 있었고이를 수행 할 수 없었습니다. Google 검색 결과 나는 method(param,payload)이 그 일을하는 방법임을 알게되었지만 제대로 작동하지 못했습니다.

다음은 내 $ 자원 공장

.factory('Dfs',['$resource',function($resource){ 
return $resource('http://'+server_ip+'/jax/search/',{}, 
{ 
    query:{method:'POST'} 
})}]) 

하고 컨트롤러에서 나는 보낼 페이로드가 도와주세요

{} 

입니다

.controller('DFl', function($scope,Dfs){ 

var d={}; 
Dfs.query(d,function(resp) 
{ 
    console.log(resp); 
}) }) 

를 호출하고 있습니다.

답변

0

간단한 POST 요청을 보내려는 경우 $http 서비스를 사용할 수 있습니다. 여기

var url = 'http://...'; 
var data = {}; 

$http.post(url, data).then(function(result) { 
    console.log(result.data); 
}); 

simple demo이다.

1

나는 여러분 모두 감사합니다 ... 일했다

ResourceName.method(payload,function(a,b){ 
     //Handle the response here 
    }) 

하나를 발견 ..