回答
protected void Application_BeginRequest() {
if (Request.Headers.AllKeys.Contains("Origin") && Request.HttpMethod == "OPTIONS"){
Response.Flush();
}
}
定义(初始化)$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-模型通过为user.FirstName
编辑:
构建$scope.user
的CreateUser
功能外
$scope.CreatUser=function(){
$http{(...)};
}
完
$ scope.FirstName = null; $ scope.LastName = null; $ scope.Email = null; $ scope.Number = null; $ scope.User = { 编号: '0', 姓: '', 名字: '', 电子邮件: '', 密码: '', 手机: '0' }; – user2951849
$ 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
我已经改变了我的代码,但仍然传递null,我也删除数据,现在我只是使用ng模型。 – user2951849
移至$ 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。
谢谢!我已经做了,但仍然没有工作。 – user2951849
因为这件事你已经发送给我,https://i.stack.imgur.com/1gjyS.png,你没有做对。您需要删除CreatUser函数 –
中的$ scope.user,如果m不发送模型并且m发送sting值但仍然发送null。你可以请检查标题和内容类型值是否可以? – user2951849
你都面临这个问题,因为你的头请求content-type
是:application/x-www-form-urlencoded
将无法正常工作。尝试将其改为application/json
- 1. 将数据发送到IP网络
- 2. 角JS - 将数据发送到.NET API控制器
- 3. 将数据从sharedpreferences发送到网络中的数据库
- 4. 发布数据到网络API
- 5. 将数据发布到角度为js的SOAP api
- 6. 如何发送节点js服务器端数据到角js
- 7. 如何使用Angular js将二进制数据发送到API
- 8. Http发送不发送数据到角js的另一个页面
- 9. 如何将数据发送到角度为REST API
- 10. 如何将数据发送到网络中的XBee?
- 11. 将数据从android发送到网络服务器
- 12. 不能发送数据从JS到PHP
- 13. 发布数据到网络
- 14. JQuery的 - $就POST不发送。数据到网络服务器
- 15. 在React.js网络应用程序发送数据到数据库
- 16. 角,JSON发送到API
- 17. 通过3G网络发送数据包
- 18. 通过网络发送sqlite数据库
- 19. 通过网络发送数据
- 20. 将物联网数据发送到Azure
- 21. 通过角度发送POST请求发送音频数据JS
- 22. 发送参数到网络服务
- 23. 数据值不发送到api。 PHP + cURL
- 24. 通过网络将数据从iphone发送到数据库安全
- 25. 发送发布数据到网络服务器 - Android
- 26. Zabbix发送发布数据到网络监控任务
- 27. 通过网络内的网络发送数据
- 28. 将数据推送到一个对象数组角JS
- 29. 发送数据到网站
- 30. 如何在Ruby中将以太网数据包发送到网络中?
使用ng-model insted的data-ng-model完全让我知道 – Jigar7521
是的,我认为Rakeschand是正确的,你需要初始化,让我来upvote – Jigar7521