RustyShackleford
RustyShackleford

Reputation: 27368

Multi page form, back button to change state

I have multi page form that has a back button built in. I want to change state when chapterID reaches 0.

$state.go executes but then redirects back to gn.newChapter state

HTML:

<a ui-sref="gn.newChapter({chapterID: id})" class="btn btn-primary"    ng-click="goBack()">Go Back</a>

Controller:

$scope.goBack = function() {
  if (newChapterService.getChapterState() === 0) {
    $state.go('gn.createGNForm');
  }
  else {
    $scope.id = newChapterService.goBackChapter();  
  }
};

Upvotes: 1

Views: 320

Answers (1)

micronyks
micronyks

Reputation: 55443

<a class="btn btn-primary"    ng-click="goBack()">Go Back</a>



$scope.goBack = function() {
  if (newChapterService.getChapterState() === 0) {
    $state.go('gn.createGNForm');
  }
  else {
    $scope.id = newChapterService.goBackChapter();  
    $state.go('gn.newChapter({chapterID: $scope.id})'); // I don't know your predefined paths. so just suggesting this as an answer. This line might be different according to your need.
  }
};

Upvotes: 1

Related Questions