<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//cdn.datatables.net/1.10.1/css/jquery.dataTables.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://rawgithub.com/DataTables/Responsive/master/css/dataTables.responsive.css" />
<style>
a {
cursor: pointer;
}
</style>
</head>
<body ng-app="datatablesSampleApp">
<article ng-controller="SimpleCtrl as showCase">
<table datatable dt-options="showCase.dtOptions" dt-column-defs="showCase.dtColumnDefs"></table>
</article>
<script data-require="jquery@1.10.1" data-semver="1.10.1" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="//cdn.datatables.net/1.10.1/js/jquery.dataTables.js"></script>
<script src="http://code.angularjs.org/1.3.5/angular.js"></script>
<script src="https://code.angularjs.org/1.3.5/angular-resource.js"></script>
<script type="text/javascript" src="https://rawgithub.com/l-lin/angular-datatables/v0.4.0/dist/angular-datatables.min.js"></script>
<script src="script.js"></script>
</body>
</html>
(function(angular) {
'use strict';
angular.module('datatablesSampleApp', ['ngResource', 'datatables'])
.controller('SimpleCtrl', SimpleCtrl);
function SimpleCtrl(DTOptionsBuilder, DTColumnDefBuilder, $compile, $scope) {
var vm = this;
vm.dataArray = [
["Superman"],
["Foo"],
["Toto"]
];
vm.dtOptions = DTOptionsBuilder.newOptions()
.withOption('aaData', vm.dataArray)
.withOption('createdRow', function(row) {
// Recompiling so we can bind Angular directive to the DT
$compile(angular.element(row).contents())($scope);
});
vm.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0).withTitle('Name').renderWith(render),
];
vm.showName = showName;
function render(data) {
return ' <a ng-click="showCase.showName(\'' + data + '\');"> ' + data + '</a>';
}
function showName(name) {
alert('Hello ' + name);
}
}
})(angular);
[
"Superman",
"Foo",
"Toto"
]