I want to itterate through elements which are in array which is in object using ng-repeat.
This is what i have done so far:
Controller:
app.controller('videoDisplayCtrl', function($scope){
var videos =
[
{
title: 'Course introduction',
pictureUrl: 'https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS_kNT5UnXz5dQ6tId9YO0wIJ7YSgRvD1SUxyfdXcXZVdOH7z4b',
length: '3:32',
category: 'IT',
subscribers: 3,
date: new Date(2014, 12, 15),
haveSubtitles: false,
comments: [
{
username: 'Pesho Peshev',
content: 'Congratulations Nakov',
date: new Date(2014, 12, 15, 12, 30, 0),
likes: 3,
websiteUrl: 'http://pesho.com/'
},
{
username: 'Pesho Peshev1',
content: 'Congratulations Nakov',
date: new Date(2014, 12, 15, 12, 30, 0),
likes: 3,
websiteUrl: 'http://pesho.com/'
},
{
username: 'Pesho Peshev2',
content: 'Congratulations Nakov',
date: new Date(2014, 12, 15, 12, 30, 0),
likes: 3,
websiteUrl: 'http://pesho.com/'
}
]
}
];
$scope.videos = videos;
console.log(videos);});
And in the view i do this:
<div ng-controller="videoDisplayCtrl">
<h2 ng-repeat="x in videos">
{{x.comments[0].username}}
</h2>
</div>
This will display only the first "username" of the first object of the "comments" array. I am missing something but i can't see what.