大家好,
我在AngularJS中创建了一个包含多列的select示例。如果我像这样直接传递值,这工作正常:
$scope.rowDatas = [
{ ID: "09-14-002880", PatientName: "PRAVEEN KUMAR", Gender: "Male", Age: "20", mobileNumber: 9879878971, patientId: "test" },
{ ID: "09-13-000188", PatientName: "VAR", Gender: "Male", Age: "20", mobileNumber: '', patientId: "ZXC12" },
{ ID: "09-05-019825", PatientName: "KARMA", Gender: "Male", Age: "29", mobileNumber: '', patientId: "ZA2545635" },
{ ID: "09-04-010524", PatientName: "FRANKLIN ANTHONY", Gender: "Male", Age: "20", mobileNumber: '', patientId: "Z7552396" },
{ ID: "09-08-009303", PatientName: "DARYOUSH", Gender: "Male", Age: "29", mobileNumber: '', patientId: "Z2548467" },
{ ID: "09-12-031048", PatientName: "SMITA", Gender: "Female", Age: "20", mobileNumber: 9880222187, patientId: "Z2296538" },
{ ID: "09-11-026001", PatientName: "ADITYA DILIP", Gender: "Male", Age: "29", mobileNumber: '', patientId: "Z2277913" }
];
但我真正需要的是我需要从工厂获得价值
dtfactory.getdata().then(function(response){
//$scope.rowDatas = response.data;
})
这里response.data
也包含相同的数据。如果我评论直接代码并取消注释工厂代码它不工作,我可能知道我错在哪里?任何人都可以帮助我。
答案 0 :(得分:0)
尝试在控制器中执行此操作
$scope.rowDatas = dtfactory.getdata().then(function(response){
$scope.rowDatas = response.data;
})
答案 1 :(得分:0)
请尝试以下代码:
首先获取json数据并调用displayTable函数:
dtfactory.getdata().then(function(response){
$scope.rowDatas = response.data;
dispalyTable();
})
function dispalyTable(){
$scope.gridOptions = {
columnDefs: $scope.gridheaders,
rowData: $scope.rowDatas,
};
//document.addEventListener('DOMContentLoaded', function() {
var gridDiv = document.querySelector('#myGrid_'+textBoxId);
new agGrid.Grid(gridDiv, $scope.gridOptions);
//});
}