How do I go to next page when a button “Press me” is pressed?
Here is my code:
<!doctype html>
<html ng-app="plunker">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.3.0.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="PaginationDemoCtrl">
<pagination num-pages="noOfPages" current-page="currentPage" max-size="maxSize"></pagination>
The selected page no: {{currentPage}}
</div>
<button>Press me</button>
</body>
</html>
3
Answers
… Your question is pretty vague, but I believe this is what you’re looking for:
In your html move your controller to the body tag and add a click event for the button
In your script add a function to handle the click event. I simply increment the current page number.
Link to Plunk
ng-controller="PaginationDemoCtrl"
to body tag.ng-click="setPage(currentPage+1)