Angularjs datatables rendering before data is fetched -


angular.module('someapp').controller('userlistsctrl',userlistsctrl);  function userlistsctrl(dtoptionsbuilder,dtcolumnbuilder,$http,$q) {     var vm = this;     function serverdata() {         var defer = $q.defer();         $.ajax({             'datatype': 'json',             'type': 'post',             'contenttype': 'application/json',             'url': 'cgi/usernavlists.py',             'data': json.stringify({'request':"inprocess"}),             'success': function(data, textstatus, jqxhr, fncallback){                 console.log("user table data coming up");                 console.log(data);                 defer.resolve(data);             },          });          return defer.promise;     }     serverdata().then(function(data){         console.log("promise data");         console.log(data);    });     vm.dtoptions = dtoptionsbuilder.fromsource('cgi/usernavlists.py').withfnserverdata(serverdata);                 console.log("user table data coming up123");     console.log(vm.dtoptions);     vm.dtcolumns = [         dtcolumnbuilder.newcolumn('requestid').withtitle('id'),         dtcolumnbuilder.newcolumn('requesttype').withtitle('type'),         dtcolumnbuilder.newcolumn('identifier').withtitle('identifier'),         dtcolumnbuilder.newcolumn('domainname').withtitle('domain name'),         dtcolumnbuilder.newcolumn('recordtype').withtitle('record type'),         dtcolumnbuilder.newcolumn('state').withtitle('state'),     ];   } 

i trying render table fetching data server. table getting render before data being fetched.i used promise job seems ain't fulfilling problem. way can make work???

you have create object asynchronous response:

angular.module('someapp').controller('userlistsctrl',userlistsctrl);  function userlistsctrl(dtoptionsbuilder,dtcolumnbuilder,$http,$q) {     var vm = this;     function serverdata() {         var defer = $q.defer();         $.ajax({             'datatype': 'json',             'type': 'post',             'contenttype': 'application/json',             'url': 'cgi/usernavlists.py',             'data': json.stringify({'request':"inprocess"}),             'success': function(data, textstatus, jqxhr, fncallback){                 console.log("user table data coming up");                 console.log(data);                 defer.resolve(data);             },          });          return defer.promise;     }     serverdata().then(function(data){         console.log("promise data");         console.log(data);     vm.dtoptions = dtoptionsbuilder.fromsource('cgi/usernavlists.py').withfnserverdata(serverdata);                 console.log("user table data coming up123");     console.log(vm.dtoptions);     vm.dtcolumns = [         dtcolumnbuilder.newcolumn('requestid').withtitle('id'),         dtcolumnbuilder.newcolumn('requesttype').withtitle('type'),         dtcolumnbuilder.newcolumn('identifier').withtitle('identifier'),         dtcolumnbuilder.newcolumn('domainname').withtitle('domain name'),         dtcolumnbuilder.newcolumn('recordtype').withtitle('record type'),         dtcolumnbuilder.newcolumn('state').withtitle('state')     ];    }); } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -