angularjs - ui-bootsrap pagination: first page button is not disabled when page loads -


i displaying list of elements inside ng-include. list of elements comes server using $resource query service.
list paginated ui-bootstrap pagination directive. server send pagination informations inside json header (properties named x-myapp-…) , intercepted query callback function.

here html :

<table ng-include src="'partials/tpllist.html'" ng-init="listinit = {'type': collec.type, 'offset': 1}" ng-controller="listctrl" > </table> 

the tpllist.html :

<tbody ng-init="loadlist(listinit)"><tr ng-repeat="elm in list">      <td>{{elm.prop1}}</td><td>{{elm.prop2}}</td><td>{{elm.prop3}}</td> </tr></tbody> <tfoot><tr><td colspan="4"> <span ng-show="pagecount>1">     <pagination num-pages="pagecount" current-page="currentpage" max-size="10" on-select-page="loadlist(collect(listinit, {offset: page}))">     </pagination> </span> </td></tr></tfoot> 

and controller:

controller('listctrl', ['$scope', 'list', function($scope, list) { // collect: concatenate objects before send loadlist()     $scope.collect = function (a,b){         var c = {};         (var att in a) { c[att] = a[att]; }         (var att in b) { c[att] = b[att]; }         return c;     }      $scope.loadlist = function (param) {         $scope.list = list.query(p, function(list, response) {             $scope.currentpage = response("x-myapp-currentpage");             $scope.pagecount = response("x-myapp-pagescount");     console.log($scope.currentpage); // returns 1 when page loads.          });      } }]) 

and service :

factory('list', function($resource){     return $resource('url/to/the/json/:type', {type:'@type'}); }) 

everything working fine except 1 thing : when page loads, first page button ("1") inside pagination component not disabled should (and "previous" , "first" buttons not either). it's not disabled until click on page number (which disabled correctly when selected) , click on first page button.

any idea ?

this happens because ng-include creates new scope , model not modified in $parent scope.

try following code or create controller communicates parent one.

<pagination num-pages="pagecount" current-page="$parent.currentpage" max-size="10" on-select-page="loadlist(collect(listinit, {offset: page}))">     </pagination> 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -