angularjs - Ajax calls to server are not getting triggered -


i unable angular-datatables request data server.

when use .fromfnpromise() works fine. code called , call service data.

  vm.dtoptions = dataoptionbuilder.fromfnpromise(         service.getviewitems()                .then(function(data) {                      vm.logs = data;                 });      )      .withpaginationtype('full_numbers')      .withdisplaylength(25); 

however, need server-side paging, i'm using .withoptions() , passing in ajax options:

    vm.dtoptions = dataoptionbuilder.newoptions()                                     .withoption('ajax', {                                         url: '/api/services/app/patients/getviewitems',                                         type: 'post'                                     })                                     .withdataprop('data')                                     .withoption('serverside', true)                                     .withoption('processing', true)                                     .withoption('order', [[0, 'asc'], [1, 'asc']])                                     .withpaginationtype('full_numbers'); 

view

<table id="dt_basic" datatable dt-options="dtoptions" dt-columns="dtcolumns" class="table table-striped table-bordered table-hover">     <thead>         <tr>             <th data-class="expand"><i class="fa fa-fw fa-lock"></i>comment</th>         </tr>     </thead>     <tbody>         <tr ng-repeat="item in vm.logs">             <td>{{ item.comment }}</td>         </tr>     </tbody> </table> 

i based code on plnkr author l-lin.

any idea on why not triggering ajax request?

according datatables reference guide, .withoption('serverside', true) means responsible implementing paging on server.

rather specify path ajax service, can use function call angular service information necessary paging (as filtering , sorting).

.withoption('ajax', function(data, callback, settings) {   //pass data parameter service access necessary paging info   service.getviewitems(data)      .then(function(result) {        callback(result);     }); }) 

here demo of hooking service option builder: http://plnkr.co/edit/1v9qdpo47xbftgvv6j2i?p=preview


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -