**控制器代码:**
$http({method: 'GET',
url: '/proj_prof_table',
params: {id: id}
}).success(function(response)
{
$scope.data = response;
$scope.emp_id = [];
$scope.emp_name = [];
$scope.billing_status = [];
$scope.mgr = [];
$scope.mgr_id = [];
$scope.stdt = [];
for(i in $scope.data)
{
$scope.emp_id.push($scope.data[i].Emp_ID);
$scope.emp_name.push($scope.data[i].Emp_Name);
$scope.billing_status.push($scope.data[i].Billing_Status);
$scope.mgr.push($scope.data[i].Manager);
$scope.mgr_id.push($scope.data[i].Mgr_ID);
$scope.stdt.push($scope.data[i].Start_Date);
}
});
// Get client timeline
// Prepare Data
$http({method: 'GET',
url: '/proj_prof_client_timeline',
params: {id: clid}
}).success(function(response)
{
$scope.data = response;
alert($scope.data);
$scope.project = [];
$scope.stdt = [];
$scope.endt = [];
$scope.x = [];
for(i in $scope.data)
{
$scope.x[i] = [];
$scope.x[i].push($scope.data[i].Proj_Name);
$scope.x[i].push($scope.data[i].Start_Date);
$scope.x[i].push($scope.data[i].End_Date);
}
alert($scope.x[0]);
});
drawChart($scope.x);
}
//time line chart
google.charts.load('current', {'packages':['timeline']});
google.charts.setOnLoadCallback(drawChart);
function drawChart(param) {
//Chart code
var container = document.getElementById('timeline');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Projects' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows(param);
chart.draw(dataTable);
}
上面的代码抛出“给 addRows 的参数必须是数字或数组”
除了 $scope.x 是一个二维数组
有没有其他方法可以将 $scope.x 定义为 [[ele,ele,ele],[ele,ele,ele],[ele,ele,ele]] 数组以将其作为参数传递给 addrows( )