AngularJS模仿Form表单提交的实现代码
废话不多说了,直接给大家贴代码了。
$http({
url:"http://localhost:10086/yuanxin/Conference/ImportExcelDataForBusRoute",
method:'Post',
headers:{
'Content-Type':'multipart/form-data'
},
data:{BusRoute:file,ConferenceID:"1"},
transformRequest:function(data,headersGetter){//进行格式转换,非常关键
varformData=newFormData();//将model转为表单格式
angular.forEach(data,function(value,key){
formData.append(key,value);
});
varheaders=headersGetter();
deleteheaders['Content-Type'];
returnformData;
}
}).success(function(data){
$scope.isSubming=false;
$scope.BusRouteColl=data.dataList;
$scope.pageIndex=1;
$scope.pageCount=data.pageCount;
//alert(data.property.mp);
}).error(function(ex,state){
alert(ex);
console.log(state+":"+ex.exceptionMessage);
console.log(ex.stackTrace);
$scope.isSubming=false;
});
以上所述是小编给大家介绍的AngularJS模仿Form表单提交的实现代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!
热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语