Day.html Showing expressions instead of Data from JSON


#1

Hello all,
I've checked my code several times, but I think I am missing something to correct. My Output of day.html showing expressions like {{day.date | datetime}} Where it should display date. Please check and help...

Day.html

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

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(err){
        return err;
  });
}]);

app.js

var app = angular.module('CalendarApp', ['ngRoute']);
app.config(function($routeProvider){
  $routeProvider
  .when('/',{
    controller:'DayController',
    templateUrl:'views/day.html'
  })
    .otherwise('/');
});

Please help !! and Thank you for your glance !! :slight_smile:


#3

@corewhiz97786,
Have you read
http://stackoverflow.com/questions/22962468/angularjs-display-current-date


#4

Error 1: In this filter, <h2 class="date"> {{day.date | datetime}} </h2>, datetime is not an acceptable term to use.

Incorrect: <h2 class="date"> {{day.date | datetime}} </h2>

Correct: <h2 class="date"> {{day.date}} </h2> OR <h2 class="date">{{day.date|date:'EEEE, M/d '}} </h2>

The Chrome console gave me this error:

Error: [$injector:unpr] http://errors.angularjs.org/1.3.15/$injector/unpr?p0=datetimeFilterProvider%20%3C-NaNatetimeFilter angular.min.js:102

At first the error seemed like gibberish to me, but at the end, it says something along the lines of NAN Time Filter. This is good to know for the future. If I see the same error, I know to look at the filters.