Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSeth Warner
1,878 PointsHow can I change the page id number in the query string, with angular and or plain Javascript.
So at the moment my site can flip through pages if I MANUALLY type out the id number at the end of the URL query string. I'd like to know how can I make a button that would allow me to increment that number or decrement that number, based off the number that is currently present.
Seth Warner
1,878 PointsSeth Kroger I'm most familiar with Ajax. My app is using Angular, so Jquery is not really an option, I think. I'm thinking I need to use a POST request, right?
1 Answer
Seth Kroger
56,413 PointsIf you're retrieving the page you should be using GET instead of POST within your service (ie., $http.get()).
In Angular I'd keep track of the current page in the controller with two functions for the buttons.
$scope.currentPage = 1;
$scope.nextPage = function() {
$scope.currentPage++;
// ...
}
$scope.prevPage = function() {
$scope.currentPage--;
// ...
}
Seth Kroger
56,413 PointsSeth Kroger
56,413 PointsAre you talking about loading into a One Page App with AJAX or loading separate webpages each time?