javascript - Pagination control changes value of model it is bound to to 1 -


as demonstrated in code below, existence of pagination (from angular directives bootstrap library) control changes value of model 1 on initial load, there way around this? have added plunker here.

<!doctype html> <html>  <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"> </head>  <body ng-app="testapp" ng-controller="testctrl">     <pagination ng-model="currentpage"></pagination>     </body>  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.17/angular.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.11.0/ui-bootstrap-tpls.min.js"></script>  <script> var testapp = angular.module('testapp', ['ui.bootstrap']);  var testctrl = function($scope) {     $scope.currentpage = 4;      $scope.$watch('currentpage', function(){         alert($scope.currentpage);     }); }  testctrl.$inject = ['$scope']; testapp.controller('testctrl', testctrl); </script>  </html> 

thanks

i believe issue aren't specifing total number of pages. try adding total-items="totalitems" directive , directive defaults 10 items per page. if have 10 items show 1. need set number of items per page.

 <pagination ng-model="currentpage" total-items="totalitems" items-per-page="itemsperpage"></pagination>     var testctrl = function($scope) {    $scope.currentpage = 4;    $scope.totalitems = 10;    $scope.itemperpage =1;     $scope.$watch('currentpage', function(){     alert($scope.currentpage);    });  } 

here demo: http://plnkr.co/edit/mzsbhzpa5lax883c5ihy?p=preview


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -