2014-03-29 78 views
0

最近我一直在做一些角搜索,在我的項目,我需要用它這是爲了將數據導出到excel file.Here是我的流程:

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

在angularjs端顯示您的路由 – karaxuna

回答

0

我解決了它。因爲我在$ location.search()之前通過了URL更改。