Routing reader chapters!

so finished the project but i had one little ambitious change i cant seem to figure out… when you are reading i wanted to add the option of going back a chapter…

In the chapterController i added a scope that lets me change the index back with
$scope.previousChapterIndex = $scope.currentChapterIndex - 1;

so in the chapter view i was able to modify the back button to…

a class=“button back” href="#/books/{{ currentBookIndex }}/chapters/{{ previousChapterIndex }}">Back</a

and voila it works! now the only problem is if you go back from chapter 1 it seems like it is making negative indexes and generates blank pages…

// If there no more chapters left, go back to the bookshelf view   

if($routeParams.chapterId >= $ - 1) {
$scope.nextChapterIndex = “#”;
this is for the forward… so i guess i want to figure out how i can make a check for doing it for previous

i actually figured it out right away… under the if statement i added…

else if($routeParams.chapterId <= 0) {
$scope.previousChapterIndex = “#”;

so it goes back to the bookshelf

i wanted to be able to go back to the book view…
i used
a class=“button” href="#/books/{{ currentBookIndex }}">Back to book<
my goal was to make it part of the back button (going to book info vs bookshelf) but couldnt figure a simple way to do that.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.