0
这里我想创建一个页面编号,每增加一次ng-repeat增量,但我得到的是第二个ng-repeat索引始终为零,但使用索引首先ng-repeat通过$ parent很好地工作。$ index这怎么解决? 这里是代码示例:
<div ng-repeat="chapter in plan.chapters" class="export-page" >
<div ng-repeat="section in chapter.sections track by section.id" class="export-page" ng-init="sectionindex = $index">
<div class="header">
<br>
<h2 class="headerTitle">
<b>{{$root.selectedCompany.name + ' | ' + chapter.subject}}</b>
</h2>
</div>
<div class="content">
<h1><b>{{chapter.subject}}</b></h1>
<h2 class="chapter" >{{section.subject}}</h2>
<br>
<p ng-if="section.content_type === 'text'">
<div ng-bind-html="section.content.text"></div>
</p>
<p ng-if="section.content_type === 'table'">
<numeric-table model="section.content"
disable-editing="true"
hide-input-controls="true">
</numeric-table>
</p>
<p ng-if="section.content_type === 'aggregated-table'">
<aggregated-table model="section.selectedTables">
</aggregated-table>
</p>
<p ng-if="section.content_type === 'text-table'">
<free-text-table model="section.content"
disable-editing="true"
hide-input-controls="true">
</free-text-table>
</p>
<p ng-if="section.content_type === 'chart'">
<multi-chart model="section.content"
tables="section.selectedTables"
>
</numeric-table>
</p>
</div>
<div class="footer col-xs-12">
<div class="txt col-xs-11">copyright [email protected] {{$root.selectedCompany.name}}</div>
<div class="pp col-xs-1 ">Page{{sectionindex}} </div>
</div>
</div>
</div>
如何是代码大块有关的问题吗?它没有ng-repeat,也没有$ index。澄清你的问题,发布相关的代码,精确解释它产生的输出,以及你想要的输出。 –
抱歉,复制粘贴问题 – mohamed