|
angular.module('datatablesSampleApp', ['datatables', 'ngResource']) |
|
.controller('SimpleCtrl', ['DTOptionsBuilder', 'DTColumnDefBuilder', 'DTInstances', '$resource', SimpleCtrl]); |
|
|
|
function SimpleCtrl(DTOptionsBuilder, DTColumnDefBuilder, DTInstances, $resource) { |
|
|
|
numeral.language('de', { |
|
delimiters: { |
|
thousands: '.', |
|
decimal: ',' |
|
}, |
|
currency: { |
|
symbol: '€' |
|
} |
|
}); |
|
numeral.language('de'); |
|
|
|
var vm = this; |
|
vm.companies = []; |
|
vm.dtOptions = DTOptionsBuilder.newOptions().withPaginationType('full_numbers').withDisplayLength(5); |
|
vm.dtColumnDefs = [ |
|
DTColumnDefBuilder.newColumnDef(0).withTitle('name') |
|
.withOption('className', 'text-left'), |
|
|
|
DTColumnDefBuilder.newColumnDef(1).withTitle('country') |
|
.withOption('className', 'text-left'), |
|
|
|
DTColumnDefBuilder.newColumnDef(2).withTitle('brandValue') |
|
.withOption('className', 'text-right') |
|
.renderWith(function(data, type, full) { |
|
return type == 'display' ? numeral(full[2]).format('0.0') : full[2]; |
|
}), |
|
|
|
DTColumnDefBuilder.newColumnDef(3).withTitle('rating') |
|
.withOption('className', 'text-left'), |
|
|
|
DTColumnDefBuilder.newColumnDef(4).withTitle('capitalization') |
|
.withOption('className', 'text-right') |
|
.renderWith(function(data, type, full) { |
|
return type == 'display' ? numeral(full[4]).format('0,0.0') : full[2]; |
|
}) |
|
|
|
//.notSortable() |
|
]; |
|
|
|
$resource('https://rawgit.com/manfredk/angular-datatables/master/data2.json') |
|
.query().$promise.then(function(companies) { |
|
vm.companies = companies; |
|
}); |
|
} |