mongodb - AngularJS ngTable not updated -


i using angular routing in application ngtable. 1 of pages contains ngtable, , search form, data coming database using get method (mongodb) every time search, every time search ngtable (table) should updated, , problem table updated 1 time, after loading page first time.

the contoller used partial page :

app.controller('searchcontroller',function($scope,ngtableparams,$http,$filter, $sce){  $scope.searching=function(){     var str = $scope.search.tags;     var tagsarry = str.split(",");      $http.get('/api/getdoc',{params:{title:$scope.search.title,tags:$scope.search.tags}})         .success(function(data)         {             if(data.notexist!=-1){                 $scope.tableparams = new ngtableparams({                     page: 1,            // show first page                     count: 10           // count per page                  }, {                     total: data.length, // length of data                     getdata: function($defer, params) {                         $defer.resolve(data.slice((params.page() - 1) * params.count(), params.page() * params.count()));                      }                 });             }           })         .error(function(err){          }); } }); 

i having same issue. need reload $scope.tableparams every time new search occurs, every time search button clicked. simple way wrap $scope.tableparams.reload() in function, , call function when search button clicked.

controller code:

$scope.dosearch = function () {     $scope.tableparams.reload(); } 

html code:

<button ng-click="dosearch()">search</button> 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -