我想要显示
光盘1轨道[1]
轨道[N]
Disc 2
轨道[1]
轨道[N]
我需要在哪里添加这些标题?
<h3>Track List:</h3>
<div ng-repeat="track in tracks">
<div ng-switch on="track.disc_number">
<div ng-switch-when="1" >
<div>
<div id="track">
{{track.track_number}}) {{track.name}}
<span>({{track.duration_ms | date : 'mm:ss'}})</span>
</div>
</div>
</div>
<div ng-switch-when="2" >
<div id="track">
{{track.track_number}}) {{track.name}}
<span>({{track.duration_ms | date : 'mm:ss'}})</span>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
这里不需要切换。
尝试阅读ng-repeat
内置filter
的文档:https://docs.angularjs.org/api/ng/directive/ngRepeat
<h3>Track List:</h3>
<div ng-repeat="disc in [1, 2]">
<h4>Disc {{disc}}</h4>
<div ng-repeat="track in tracks | filter: {disc_number: disc}">
<div id="track">
{{track.track_number}}) {{track.name}}
<span>({{track.duration_ms | date : 'mm:ss'}})</span>
</div>
</div>
</div>