我想在嵌套的 ng-repeat 中显示一个索引

I want display one index in nested ng-repeat

我要写:

正文正文

1 我的问题是正确的

2 我的问题是正确的

正文正文

3 我的问题是正确的

4 我的问题是正确的

5 我的问题是正确的

正文正文

6 我的问题是真的

7 我的问题是真的

<span ng-repeat="step in steps">
    <b>{{step.statement}}</b><br>
    <span ng-repeat="question in step.questions">
        <b>{{??????}}</b>  {{question.question}} {{question.response}}<br>
    </span>
</span>

我用 $index+1 测试:1 2 1 2 3 1 2

我测试 $parent.$index+1: 1 1 2 2 2 3 3

但我想要 1 2 3 4 5 6 7 ...

可以把前面循环的length往前加到下一个$index。像这样:

<div ng-init="lastLength=[]">
      <span ng-repeat="step in steps" ng-init="lastLength[$index]=step.questions.length">
            <b>{{step.statement}}</b><br>
            <span ng-repeat="question in step.questions" style="padding-left:50px;">
                <b>{{lastLength[$parent.$index-1]+$index+1}}</b>  {{question.question}} {{question.response}}<br>
            </span>
      </span>
</div>

工作示例:

var app = angular.module('xApp', []).controller('xCtrl', function($scope) {
  $scope.steps = [{
    statement: 'St 1',
    questions: [{
      question: 'q 1',
      response: 'rs 1'
    }, {
      question: 'q 2',
      response: 'rs 2'
    }]
  }, {
    statement: 'St 2',
    questions: [{
      question: 'q 4',
      response: 'rs 4'
    }, {
      question: 'q 5',
      response: 'rs 5'
    }, {
      question: 'q 6',
      response: 'rs 6'
    }]
  }]
})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="xApp" ng-controller="xCtrl" ng-init="lastLength=[]">
  <span ng-repeat="step in steps" ng-init="lastLength[$index]=step.questions.length">
        <b>{{step.statement}}</b><br>
        <span ng-repeat="question in step.questions" style="padding-left:50px;">
            <b>{{lastLength[$parent.$index-1]+$index+1}}</b>  {{question.question}} {{question.response}}<br>
        </span>
  </span>
</div>