javascript - ng-table reload does not work -


i created ng-table like:

data = $scope.publications;         $scope.tablepublications = new ngtableparams({        page: 1,            // show first page        count: 20      // count per pages     }, {        total: data.length, // length of data        getdata: function($defer, params) {            // use build-in angular filter            var ordereddata = params.sorting() ?                                $filter('orderby')(data, params.orderby()) :                                data;         $defer.resolve(ordereddata.slice((params.page() - 1) * params.count(), params.page() * params.count()));    } }); 

when searching, function called retrieves info api , calls reloadtable function:

$scope.reloadtable = function(publications){     $scope.tablepublications.data = publications;     $scope.tablepublications.reload();     $scope.tablepublications.reloadpages();   } 

now $scope.tablepublications.data has new information .reload() doesn't work , doesn't refresh table.

i change code that

$scope.search = function(page){     if($scope.searchtext!=="" || $scope.searchtext !== "undefined")     {         $scope.issearch=true;         minisite.searchpublications({search: $scope.searchtext, page: page}, function(publications){             $scope.total=publications.total;             $scope.publications = publications.publications;             $scope.tablepublications.data = {};             $scope.tablepublications.reload();         });     } } 

minisite factory retrieve hash api, , reloaded tablepublications doesn´t work. have similar code in other functions , work fine , dont understand it.

actually, since outside of digest cycle given calling api, should try $scope.$apply() so:

$scope.$apply(function() {     $scope.reloadtable = function(publications){         $scope.tablepublications.data = publications;         $scope.tablepublications.reload();         $scope.tablepublications.reloadpages();     } }); 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -