2016-04-14 76 views

回答

0

我發現我自己的一個解決方案.. 這裏是在服務器端控制代碼...

 con.query("CALL `sp_tviselect`", function(err, result) { 
     if(err){ 
      throw err; 
     } else { 
      //console.log(result); 
      res.send(JSON.stringify(result)); 
     } 
    }); 

這裏是在客戶端控制器上的代碼

$http.get('/api/tvi/list') 
    .success(function(data) { 
    var newObj = {}; 
    for(i=0; i<data.length; i++) 
    { 
     newObj[i]=data[i]; 
    } 
    $scope.gridOptions.data = newObj[0]; 
     newObj[0].forEach(function addRows(row, index){ 
     row.businesstype = row.businesstype==='DTI' ? '1' : '2'; 
     }); 
    }); 

首先我將原始數據口袋轉換成json字符串格式。然後在客戶端,我得到索引爲0的數組的列表元素,然後將其放到對象變量中。

我希望這會幫助其他人。謝謝