$ http.post无法将对象发送到控制器WebAPi [英] $http.post can not send object to controller WebAPi

查看:76
本文介绍了$ http.post无法将对象发送到控制器WebAPi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在学习Angularjs。我有一个代码:

controller.js

 $ scope.save = function( position){
$ http.post(serviceBase +'Positions',{model:$ scope.position})
.success(function(data){
});



$ scope.position 已经返回一个对象 {Name:名称,描述:描述{

在api:

 [HttpPost] 
public HttpResponseMessage发布(职位模特)
{
}





但是在api我无法获得模特。它的属性为null。

请帮我这个代码。谢谢。

我已经尝试过:

 $ http.post(serviceBase +'Positions',$ scope.position)



但它是一样的。

解决方案

scope.save = function(position){


< blockquote> http.post(serviceBase +'Positions',{model:


scope.position})
.success(function(data){
});




Hi all,
i am learning Angularjs . i have a code:
controller.js

$scope.save = function (position) {
           $http.post(serviceBase + 'Positions', { model: $scope.position })
              .success(function (data) {
                            });


$scope.position already returns an object {Name: "Name",Description:"Description"{
In api:

[HttpPost]
public HttpResponseMessage Post(Position model)
{
}



But in api i can not get model . It's properties are null.
Pls help me in this code. Thanks.
I already have tried :

$http.post(serviceBase + 'Positions', $scope.position) 


But it is same.

解决方案

scope.save = function (position) {


http.post(serviceBase + 'Positions', { model:


scope.position }) .success(function (data) { });



这篇关于$ http.post无法将对象发送到控制器WebAPi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆