I am beginner in AngularJS and facing some issues. I am trying to make a questionnaire having 1 question on each page. On every Next button data is save in the database. I am tr
You could save your showDiv booleans in an array, and keep the corresponding index in memory. So something like this:
$scope.currentState = 0;
//ordered representation of possible states
$scope.stateArray = [true, false, false, false, false];
$scope.next = function(){
//on to the next showDiv
currentState++;
stateArray.forEach(function(index, state){
//hide everything else.
if(index != currentState){
state = false;
}
else{
state = true;
}
}
}
Then, in your html, do ng-show="stateArray[currentState]"
You'll inadvertently gain a "previous" function from this if you choose by decrementing the currentState instead.