直接上示例代码,有不懂的欢迎留言:

 

$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) {//进行格式转换,非常关键
             var formData = new FormData();//将model转为表单格式
             angular.forEach(data, function (value, key) {
                   formData.append(key, value);
             });
             var headers = headersGetter();
             delete headers['Content-Type'];
             return formData;
     }
}).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;
});

 

相关文章:

  • 2021-12-21
  • 2021-12-04
  • 2021-12-08
  • 2022-02-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
  • 2021-11-09
  • 2022-12-23
  • 2021-11-29
  • 2021-12-12
相关资源
相似解决方案