2016-10-27 34 views

回答

1
protected void Application_BeginRequest() { 
    if (Request.Headers.AllKeys.Contains("Origin") && Request.HttpMethod == "OPTIONS"){ 
    Response.Flush(); 
    } 
} 
3

定义(初始化)$FirstNameLastNameEmail,Number为空。

$scope.FirstName = null; 
$scope.LastName = null; 
$scope.Email = null; 
$scope.Number = null; 

,或者你可以只使用$scope.user

$scope.user = { 
    id : 0, 
    FirstName : null, 
    LastName : null, 
    Email : null, 
    Password : null 
}; 

而在NG-模型通过为user.FirstName

编辑:

构建$scope.userCreateUser功能外

$scope.CreatUser=function(){ 
    $http{(...)}; 
} 

+0

$ scope.FirstName = null; $ scope.LastName = null; $ scope.Email = null; $ scope.Number = null; $ scope.User = { 编号: '0', 姓: '', 名字: '', 电子邮件: '', 密码: '', 手机: '0' }; – user2951849

+0

$ scope.CreateUser = function(){ 调试器; $ HTTP({ 方法: 'POST', 数据类型: 'JSON', URL: 'HTTP://本地主机:50048/API/SingUp /后', 数据:$ scope.User, 标头:{ 'content-Type':'application/x-www-form-urlencoded'} })。 ); alert(“Successfully !!!”); },function errorCallback(response){ }); }; – user2951849

+0

我已经改变了我的代码,但仍然传递null,我也删除数据,现在我只是使用ng模型。 – user2951849

1

移至$ scope.User控制器范围:

app.controller('myCtrl',function($scope,$http){ 
    $scope.User = { 
    id : 0, 
    FirstName : null, 
    LastName : null, 
    Email : null, 
    Password : null 
    }; 

    $scope.CreatUser=function(){ 
     $http{(...)}; 
    } 

}) 

,并传递NG-模型User.FirstName。

+0

谢谢!我已经做了,但仍然没有工作。 – user2951849

+0

因为这件事你已经发送给我,https://i.stack.imgur.com/1gjyS.png,你没有做对。您需要删除CreatUser函数 –

+0

中的$ scope.user,如果m不发送模型并且m发送sting值但仍然发送null。你可以请检查标题和内容类型值是否可以? – user2951849

1

你都面临这个问题,因为你的头请求content-type是:application/x-www-form-urlencoded将无法​​正常工作。尝试将其改为application/json