Project Calendar- doesn't show data


#1

DayController.js

app.controller('DayController', ['$scope', 'events', function($scope, events) {
  
  events.success(function(data){
    $scope.day=data;
  })

}]);

events.js

app.factory('events', ['$http', function($http){
  return $http.get('https://s3.amazonaws.com/codecademy-content/courses/ltp4/events-api/events.json')
  .success(function(data){
    return data;
  })
  .error(function(error){
    return error;
  })
}]);

index.html

<!doctype html>
<html>
  <head>
    <link href="https://s3.amazonaws.com/codecademy-content/projects/bootstrap.min.css" rel="stylesheet" />
    <link href="css/main.css" rel="stylesheet" />
    <script src="js/vendor/angular.min.js"></script>
    <script src="https://code.angularjs.org/1.2.28/angular-route.min.js"></script>

  </head>
  <body ng-app="CalendarApp">
    <div class="header">
      <div class="container">
        <img src= "img/logo.svg" width="51" height="54">
      </div>
    </div>
    <script src="https://code.angularjs.org/1.2.28/angular-route.min.js"></script>
    <div class="main">
      <div class="container">

        <div ng-view></div>

      </div>
    </div>

    <!-- Modules -->
    <script src="js/app.js"></script>

    <!-- Controllers -->
    <script src="js/controllers/DayController.js"></script>
    <script src="js/controllers/EventController.js"></script>

    <!-- Services -->
    <script src="js/services.events.js"></script>

  </body>
</html>

day.html

<!-- Format a date so it displays in the format "Friday 1/16" -->
<h2 class="date"> {{day.date}} </h2>



<div class="event" ng-repeat='event in day.events' >
  <a href="#/{{$index}}">
    <h3 class="name"> {{event.name}} </h3>
    <p><span class="from"> {{event.from}} </span> - <span class="to"> {{event.to}}  </span></p>
  </a>
</div>

app.js

var app = angular.module('CalendarApp', ['ngRoute']);

app.config(function($routeProvider){
  $routeProvider
  .when('/',{
    controller: 'DayController',
    templateUrl: 'views/day.html'
  })
  .otherwise({
    redirectTo: '/'
  })
})


#2

please can someone tell me what is wrong about my code? I have watched the video of the instructions and it looks like I wrote the same codeā€¦


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.