javascript - AngularJS - Pagination not rendering on $scope.Watch change (CodePen included) -
question background:
i'm learning angularjs. have created simple app takes in 3 form inputs, , on submission of form paginated list should rendered. have dependancy on ui-bootstrap. plnkr showing pagination example i'm attempting incorporate app: http://plnkr.co/edit/81fpzxpnoqnihqgp957q?p=preview
the issue & demo:
this link code far on codepen:
http://codepen.io/daveharris/pen/nnmqyy
i have list of 1000 items populating on searchingservice
model injected , shared between 2 controllers.
i cannot paginated ng-repeat
populate when searchingservice.searchlist
list on searchingservice
model changed, if $scope.watch
not being triggered.
any getting bottom of appreciated.
as bchemy pointed out, $watch
should changed $watchcollection
. change won't enough have app working correctly current code, since pagination looks broken.
you should add watcher control pagination 1 in example want replicate:
$scope.$watch('currentpage + numperpage', function() { var begin = (($scope.currentpage - 1) * $scope.numperpage) , end = begin + $scope.numperpage; $scope.filtereditems = $scope.searchingservice.searchlist.slice(begin, end); });
also $scope.items
array getting duplicate searchlists
in , mess pagination length.
i have created plunker can see example working.
Comments
Post a Comment