最近我在Angular中做了一些搜索,在我的项目中,我需要使用它来将数据导出到excel文件。这是我的流程:
Get querystirng -> send to express -> output file
服务模块:
factory('getExcel', function($http,$location,$route){
return {
getData: function(callback){
var queryString = $location.search();
console.log('queryString',queryString); //empty object
console.log('route', $route.current.params) //empty object
return $http({
method:'GET',
url: '/Excel',
params:{
... // This will send to express,but I got nothing
}
}).success(callback);
}
}
});
控制器模块:
controller('someCtrl', function(getExcel){
$scope.exportExcel = function(){
....
getExcel.getData()
....
}
});
快递:
app.get('/Excel', function(req, res) {
//wait for data
console.log(req.query);
res.end();
});
答案 0 :(得分:0)
我解决了。因为我在$ location.search()之前传递了更改URL。