2015-10-14 69 views
0

这里传递一个数据表到WCF服务是使用了数据表中要求我的WCF服务:我想用angularjs

[OperationContract] 
[WebInvoke(Method = "POST", UriTemplate = "/checkout", 
       BodyStyle = WebMessageBodyStyle.Bare, 
       RequestFormat = WebMessageFormat.Json, 
       ResponseFormat = WebMessageFormat.Json)] 
      void Checkout(UserDetails data); 

这是我的客户端代码:

$scope.checkout = function() { 
      var data = { 
       "MemberID": "2500394300", 
       "CategoryID": "1", 
       "ProductID": "1", 
       "PointValue": "100" 
      }; 
      $http.post(
       "url", 
       data, 
       { 
        headers: { 
         'Content-Type': 'application/json' 
        } 
       } 
      ).success(function (result) { 

       alert(result); 
      }); 

     } 
+0

您应该使用json数据以方便使用。 – Chandermani

回答

0

应该转换data变量为JSON字符串:

$http.post(
    "url", 
    JSON.stringify(data) 
+0

是的,我之前这样做,但它显示400坏请求 – user2844300