In a multi step form, I have a previous, next directive that gets the current step and saves it in session storage variable. All of the information on step 1 template that the user fills out is stored in a $scope.section1 object. I want to keep saving "section2", "section3" on clicking next on each of the step. how do I generate the $scope.section1, $scope.section2 dynamically? I want to preserve the notation "section1", "section2" etc.
$sessionStorage[currindex] = $scope.section1;
Controller:
$scope.nextPage = function(){
var currindex = $scope.getIndex();
var nextindex = ++currindex;
//storing in session
$sessionStorage[currindex] = $scope.section1;
}
Directive:
<nav>
<ul class="pager">
<li class="previous" ng-click="prevPage()" ng-class="{disabled: prevPageDisabled == true}"><a href><span aria-hidden="true">←</span>Previous</a></li>
<li class="btn btn-lg" ng-click="saveAll()"><a href><span aria-hidden="true">Save</span></a></li>
<li class="next" ng-click="nextPage()" ng-class="{disabled: nextPageDisabled == true}"><a href><span aria-hidden="true">→</span>Next </a></li>
</ul>
</nav>