多页表单,后退按钮改变状态

Multi page form, back button to change state

我有一个内置后退按钮的多页表单。我想在 chapterID 达到 0 时更改状态。

$state.go 执行但随后重定向回 gn.newChapter 状态

HTML:

<a ui-sref="gn.newChapter({chapterID: id})" 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();  
  }
};
<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.
  }
};