使用来自JSON数组的ng-repeat显示数据

时间:2015-12-08 19:15:51

标签: javascript angularjs json

这是我的JSON数据:

$scope.track = [{
        title: 'Group Therapy 150 with Above & Beyond and Maor Levi',
        date: new Date(),
        link: "https://www.mixcloud.com/widget/iframe/?embed_type=widget_standard&embed_uuid=a38e8d96-7372-430b-91b3-7549a408ac7c&feed=https%3A%2F%2Fwww.mixcloud.com%2FPlayLifePodcast%2Fdj-nyk-play-life-podcast-003%2F&hide_cover=1&hide_tracklist=1&replace=0",
        tracklist: ['Adam Rickfors - Twang Machine (Original Mix)', 'Cirez D - On Off (Tannergaard Remode)', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats', 'Matt Nash & Felix Leiter - Heartbeats'],
        guest: 'Guest Mix by Pep & Rash',
        guestlist: ['Tom Staar - Bora / S.H.M - Save The World', 'Dimitri Vegas, Like Mike, Ne-Yo - Higher Place (Tujamo Remix)', 'New_ID & Funk Machine - I Wanna Move', 'Knife Party - Lrad', 'Knife Party - Lrad', 'Knife Party - Lrad', 'Knife Party - Lrad', 'Knife Party - Lrad', 'Knife Party - Lrad']
    }]

这就是我访问它的方式:

<div id="podcast-wrapper">
    <h1>{{track.title}}</h1>
    <h4>{{track.date | date}}</h4>
    <iframe width="100%" height="180" ng-src="{{track.link | trustAsResourceUrl}}" frameborder="0"></iframe>
    <div class="row">
        <div class="col-sm-6">
            <h3>TrackList</h3>
            <ul>
                <li ng-repeat="song in track.tracklist">{{song}}</li>
            </ul>
        </div>
        <div class="col-sm-6">
            <h3>{{track.guest}}</h3>
        </div>
    </div>
</div>

标题,日期,来宾名称按预期显示,但我无法使用ng-repeat显示li元素内的曲目列表。

感谢任何帮助,谢谢。

1 个答案:

答案 0 :(得分:1)

You can not have duplicate entries in arrays if you want to loop over them in COLS. https://docs.angularjs.org/error/ngRepeat/dupes