2015-01-30 2 views
0

안녕하세요 어떻게 내가 각도로 Http 에서이 개체를 매개 변수로 전달할 수 있습니까? 내 WCG 공공 무효 CreateNewAccount (사용자 우리)

$scope.RegisterUser = function(){ 
var us = { 
    UserName:$scope.userName, 
    Password:$scope.password, 
    UserRoleID:null, 
    Company:$scope.company, 
    Terms:$scope.terms, 
    ID:null, 
    BuyerID:app.buyerId 
}; 

$http.get(
    app.wcf+'/CreateNewAccount'angular.toJson({us:us})) 
    .then(
    function(resp){ 
    app.Logger(resp.data); 
    }, 
    function(err){ 
     app.Logger(err); 
})}; 
+0

를 호출이 그것을 솔기를 받고 있어요? –

+0

은 wcf 일 수 있지만 atm은이 객체를 보내는 방법을 얻거나 get 할 수 없습니다. – vivid

답변

3

합니다.

$http.get(app.wcf + '/CreateNewAccount', {params: us}) 
    .then(function(resp){ 
    app.Logger(resp.data); 
    }, 
    function(err){ 
    app.Logger(err); 
})}; 

은 특히하지 쿼리 문자열에 사용자 이름과 암호를 사용하는 GET 요청으로이 데이터를 전달하지 말아야 말했다. 이 게시물이어야한다 -

+0

Thx :) 새로운 플랫폼을 테스트하고 있습니다. – vivid

+0

톰 게시 요청을 위해이 내용을 수정할 수 있습니까? – vivid

+0

@Alex,'http http : // http.post (app.wcf + '/ CreateNewAccount', us) .then (...)' – Tom

1

get를 들어, PARAMS 사용해야하기 때문에 : 당신은 $http.get(url, config) 방법의 설정에 params 같은 개체를 전달해야

$http({method:'GET', url:'url', params:us}) 
+0

$ http ({메서드 : '가져 오기', url : app.wcf + '/ 매개 변수 : us}}) 맞습니까? – vivid

+0

예. 맞습니다. – pixelbits

+0

데이터로 게시하는 방법 : – vivid

-1

나는 왜이있는`$의 get`을하고있는 옵션 Remote Address:192.168.58.182:80 Request URL:http://192.168.58.182/ESService/ESService.svc/CreateNewAccount Request Method:OPTIONS Status Code:405 Method Not Allowed Request Headersview source Accept:*/* Accept-Encoding:gzip, deflate, sdch Accept-Language:en-US,en;q=0.8,pl;q=0.6 Access-Control-Request-Headers:accept, content-type Access-Control-Request-Method:POST Connection:keep-alive Host:192.168.58.182 Origin:http://localhost:8100 Referer:http://localhost:8100/ User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36 Response Headersview source Access-Control-Allow-Headers:Content-Type, Accept Access-Control-Allow-Methods:POST,GET,OPTIONS Access-Control-Allow-Origin:* Access-Control-Max-Age:1728000 Allow:POST Content-Length:1565 Content-Type:text/html; charset=UTF-8 Date:Fri, 30 Jan 2015 14:10:34 GMT Server:Microsoft-IIS/7.5 X-Powered-By:ASP.NET