无法从AngularJS调用Laravel Controller时下载Excel文件

时间:2017-07-13 09:48:16

标签: php angularjs laravel-5 laravel-5.2

您好我正在从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');

0 个答案:

没有答案