0

I can't seem to iterate over a JSON object using ng-repeat. I did test it directly by index and it works, but just can't seem to loop and print. What am I doing wrong? JSFiddle link.

Here's my code:

<div ng-app="myApp">

<div ng-controller="Ctrl">

    <h3>Upcoming Events</h3>

    <ul ng-repeat="event in events">
        <li>{{ event.feed.entry.title.$t }}</li>    
    </ul>

    <!-- testing single entry here - it works! -->
    <small>{{ events.feed.entry[0].title.$t }}</small>

</div>

</div>

The script:

var app = angular.module('myApp', []);
var feedUrl = 'https://www.google.com/calendar/feeds/ogmda.com_89pas0l9jbhpf053atd83hdj30%40group.calendar.google.com/public/basic?alt=json';

app.controller('Ctrl', function($http, $scope) {
$http.get(feedUrl).success(function(data) {
    $scope.events = data;
    });
});
2
  • Your JsFiddle isn't going to work because it's blocked by CORS. Commented Oct 3, 2015 at 12:10
  • jsfiddle.net/t3ydLvot Commented Oct 3, 2015 at 12:16

1 Answer 1

1

That's because you iterate over the whole data returned by the calendar query, and not over the entries themselves. Change your ul to:

<ul ng-repeat="entry in events.feed.entry">
    <li>{{ entry.title.$t }}</li>    
</ul>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.