当我尝试使用ui-grid从我的webAPI显示json数据时,我在AngularJS前端出现以下错误。
1.angular.merge is not a function at Object.add (ui-grid.js:13493) 2.[$injector:cdep] Circular dependency found: uiGridGridMenuService <- uiGridMenuButtonDirective 3.[$injector:cdep] Circular dependency found: uiGridColumnMenuService <- uiGridColumnMenuDirective 4.[$injector:cdep] Circular dependency found: GridColumn <- Grid <- gridClassFactory
test.html
<div style="overflow-y:scroll;height:300px">
<table st-table="rowCollection" ng-class="panel-body12" class="table table-striped">
<thead>
<tr>
<th style="text-align:center">Name</th>
<th style="text-align:center">Type</th>
</tr>
</thead>
<tbody>
<tr>
<td ui-grid="gridOptions"></td>
</tr>
</tbody>
</table>
Index.html
已推荐-
<script src="http://ui-grid.info/release/ui-grid.js"></script>
<link rel="stylesheet" href="http://ui-grid.info/release/ui-grid.css" />
控制器
var empDetails = {
CompanyID: CompanyID,//taken from Login page
PlanName: getName(0),
EmployerName: getName(1),
TPAName: getName(2),
PlanID: getID(),
PayorID: getID(),
TPAPlanID: getID(),//not used for SBGC
PlanType: $scope.plantypeselected,//not used for SBGC
StateProv: $scope.stateselected,
PostalCode: $scope.zip
};
$scope.employeeList = [];
$http({
method: 'Post',
url: 'http://localhost:121212/api/Values/PostEmployeeData',
dataType: 'json',
data: $.param(empDetails),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).success(function (data) {
$scope.object = data;
$scope.employeeList = data;
$scope.gridOptions = { data:'employeeList'};
}).error(function (error) {
alert('There is an error');
});
WebAPI
[Route("PostEmployeeData")]
[HttpPost]
public DataTable PostEmployeeData([FromBody]Employer empDetails)
{
DataTable dataTable1 = new DataTable { TableName = "MyTableName" };
dataTable1 = empData.getEmployeeData(empDetails);
return dataTable1;
}