答案 0 :(得分:4)
首先定义(初始化)$FirstName
,LastName
,Email
,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-model作为user.FirstName
修改强>
在$scope.user
功能
CreateUser
$scope.CreatUser=function(){
$http{(...)};
}
<强> ENDS 强>
答案 1 :(得分: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-model作为User.FirstName传递。
答案 2 :(得分:1)
protected void Application_BeginRequest() {
if (Request.Headers.AllKeys.Contains("Origin") && Request.HttpMethod == "OPTIONS"){
Response.Flush();
}
}
答案 3 :(得分:1)
您遇到此问题,因为您的标头请求content-type
是:application/x-www-form-urlencoded
无法正常运行。尝试将其更改为application/json