大佬教程收集整理的这篇文章主要介绍了angularjs表单数据提交-对象方式提交,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
1.HTML代码
<body ng-app="Power" ng-controller="userCtrl" ng-init="initData()"> 用户名:<input type="text" ng-model="user.username" /><br/> 密码:<input type="text" ng-model="user.password" /> <input type="button" value="提交" ng-click="saveUser()" /> </body>
this.saveUser=function(user){ var deferred = $q.defer(); $http.get("userAction!doNotNeedSession_add.action",{ params:user//传整个表单数据 }).@R_673_6048@s(function (data) { // 如果连接成功,延时返回给调用者 deferred.resolve(data); }) .error(function () { deferred.reject('连接服务器出错!'); }) return deferred.promise; };
3.controller代码
@H_618_16@$scope.user={username:'',password:''}; $scope.saveUser=function () { userservice.saveUser($scope.user).then(function (data) { console.info(data); }); };以上是大佬教程为你收集整理的angularjs表单数据提交-对象方式提交全部内容,希望文章能够帮你解决angularjs表单数据提交-对象方式提交所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。