您好我正在从angularjs向laravel控制器发送一些数据,并根据该数据我想从sql表中获取数据并下载为excel文件。但是我无法下载文件
角度代码
$scope.sendSetField = function (selected_list) {
var arr = [];
angular.forEach(selected_list, function(value, key){
arr.push(key);
});
//console.log(selected_list);
$http.post("http://localhost/maxo_ats_v1.00/dashboard/jobsDownload",arr)
.then(function(response) {
});
Laravel控制器:
public function downloadJobsList(Request $request)
{
// $jobs = CnfFormField::select('id', 'name', 'email', 'created_at')->get();
$jobs = Input::all();
// return view('jobs.columnSelect',compact['data']);
$data = Jobs::select($jobs)->get();
Excel::create('Job', function($excel) use ($data) {
$excel->sheet('mySheet', function($sheet) use ($data)
{
$sheet->fromArray($data);
});
})->download('xlsx');
}
路线
Route::post('dashboard/jobsDownload','JobsController@downloadJobsList');