且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

$ http.post无法将对象发送到控制器WebAPi

更新时间:2023-02-13 09:32:54

scope.save = function(position){


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) { });