angularjs uigrid 未加载数组
angularjs uigrid not loading array
angularjs 中的 uigrid 未加载数组对象。当我将 select 查询更改为存储过程时发生此错误。
这里是使用存储过程返回的结果
enter image description here
此数组结果不显示数据。
这里是使用显示数据的 select 查询返回的结果。如何将数组数据更改为对象?
enter image description here
我自己找到了解决方案..
这是服务器端控制器的代码...
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的数组的列表元素,然后把它放到对象变量中。
我希望这对其他人有所帮助。谢谢
angularjs 中的 uigrid 未加载数组对象。当我将 select 查询更改为存储过程时发生此错误。
这里是使用存储过程返回的结果 enter image description here 此数组结果不显示数据。
这里是使用显示数据的 select 查询返回的结果。如何将数组数据更改为对象? enter image description here
我自己找到了解决方案.. 这是服务器端控制器的代码...
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的数组的列表元素,然后把它放到对象变量中。
我希望这对其他人有所帮助。谢谢