我的问题是我想根据 2 个嵌套 ng-repeat 指令的索引动态生成范围变量。当我在 DOM 中显示该表达式时,它可以正常工作,但 ng-bind 内部的相同则不起作用。($index 有效,但 $parent.$index 无效)这是我的代码:
<div class="panel panel-primary" ng-repeat="device in home.devices">
<div class="panel-heading">
<h3 class="panel-title pull-right">
<a href="#settings">
<em class="fa fa-cog"></em>
</a>
</h3>
<h3 class="panel-title" ng-bind="::device.name"></h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-4 text-center" ng-repeat="sensor in device.sensors">
<div class="panel panel-default">
<div class="panel-body">
<h2 ng-if="device.type == 'bm'" ng-bind="t{{$parent.$index}}{{$index}}"></h2>
t{{$parent.$index}}{{$index}}
</div>
</div>
</div>
</div>
</div>
</div>