Click here to Skip to main content
15,895,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML:

HTML
<html>
<head>
@* CSS *@
<styles>
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<link href="~/Content/DataTables-1.10.12/media/css/jquery.dataTables.css" rel="stylesheet" />
<link href="~/Content/DataTables-1.10.12/media/css/jquery.dataTables.min.css" rel="stylesheet" />
</styles>
<scripts>
<scripts src="~/scripts/jquery-1.9.1.js"></scripts>
<script src="~/scripts/DataTables-1.10.12/media/js/jquery.dataTables.js"></script>
<script src="~/scripts/angular.js"></script>
<script src="~/scripts/src/angular-datatables.js"></script>
<script src="~/scripts/myApp.js"></script>
</scripts>
@* JS for angularJS and Datatable *@
</head>
<body>
<div ng-app="MyApp" class="container">
<div ng-controller="homeCtrl">
<table id="entry-grid" datatable="" dt-options="dtOptions" dt-columns="dtColumns" class="table table-hover"></table>
</div>
</div>
</body>
</html>


Javascript:

JavaScript
var app = angular.module('MyApp', ['datatables']);
app.controller('homeCtrl', ['$scope', '$http', 'DTOptionsBuilder', 'DTColumnBuilder',
function ($scope, $http, DTOptionsBuilder, DTColumnBuilder) {
$scope.dtColumns = [
DTColumnBuilder.newColumn("EmployeeName", "EmployeeName"),
DTColumnBuilder.newColumn("Department", "Department"),
DTColumnBuilder.newColumn("DateofBirth", "DateofBirth"),
DTColumnBuilder.newColumn("Designation", "Designation"),
DTColumnBuilder.newColumn("ReportingManager", "Reporting Manager")
]
$scope.dtOptions = DTOptionsBuilder.newOptions().withOption('ajax', {
url: "/Datatable/GetAlldata",
type: "GET"
})
.withPaginationType('full_numbers')
.withDisplayLength(10).withButtons([
'columnsToggle',
'colvis',
'copy',
'print',
'excel',
{
text: 'Some button',
key: '1',
action: function (e, dt, node, config) {
alert('Button activated');
}
}
]);
}]);


What I have tried:

hi guys i used angular datatable i completed every thing but am getting some Error which showned by image below .how to rectify this Error:

C#
Error:
 
[$injector:modulerr] Failed to instantiate module MyApp due to:
Error: [$injector:modulerr] Failed to instantiate module datatables due to:
Posted
Updated 17-Nov-16 1:44am
v3
Comments
Konstantin A. Magg 6-Nov-16 6:27am    
Hi, is this the full log message you posted? Reads to me like the error message from the Angular injector got cut at the end.

1 solution

You can you the existing $http service for the ajax call you have made in above code and made the change accordingly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900