# Load DataTables options/ columns/ columnDefs with promise

Sometimes, your DataTable options/columns/columnDefs are stored or computed server side. All you need to do is to return the expected result as a promise.

<tabset>

angular.module('datatablesSampleApp', ['datatables']).controller('LoadOptionsWithPromiseCtrl', LoadOptionsWithPromiseCtrl); function LoadOptionsWithPromiseCtrl($q, $resource) { var vm = this; vm.dtOptions = $resource('/angular-datatables/dtOptions.json').get().$promise; vm.dtColumns = $resource('/angular-datatables/dtColumns.json').query().$promise; }

dtOptions.json

{ "ajax": "/angular-datatables/data.json", "dom": "pitrfl", "pagingType": "full_numbers" }

dtColumns.json

[{ "data": "id", "title": "ID" }, { "data": "firstName", "title": "First name" }, { "data": "lastName", "title": "Last name", "visible": false }]
</tabset>