我正在尝试以2x2矩阵格式重复4个元素,顶部和底部分开的行。为此,我使用ng-repeat重复顶部和底部行,然后使用另一个ng-repeat内部重复这两个元素。我已经完成了并获得了所需的格式。但我的问题是我需要为这4个元素(div)提供不同的标题。如何在数组中给出标题,以便在两行中重复?以下是我的代码:
<div class="massage-type-section" ng-controller="massageController">
<div class="select-massage-type" ng-repeat="item in massage">
<div class="massage-choice" ng-repeat="type in massageType">
<div class="massage-choice-icon">
<img src="images/single-icon-deselect.png">
<img src="images/single-icon.png">
</div>
<p class="massage-title">{{type.title}}</p>
<p class="section-details">One massage practitioner comes to massage one person.</p>
<div class="type-selected"><img src="images/selected.png"></div>
</div>
</div>
</div>
function massageController($scope) {
$scope.massage = [{}, {}];
$scope.massageType = [
{ title: 'Single' },
{ title: 'Couple' }
];
};
答案 0 :(得分:0)
如果你在内部数组中的主要要求只是显示按摩类型标题,那么你的数组看起来很好。如果有帮助,请标记为答案。
答案 1 :(得分:0)
如果您的要求是在不同级别提供不同的标题,请以适当的方式使用$ index或$ parent。$ index。
要查找集合中项目的索引,请使用$ index属性 获取父元素的索引 使用$ parent。$ index或 使用ng-init =&#34; parentIndex = $ index&#34;