直接上示例代碼,有不懂的歡迎留言: ...
直接上示例代碼,有不懂的歡迎留言:
$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; });