The photo detail information is not showing in the view. I have checked my code against the one in GitHub and it looks exactly the same. What are the usual suspects in these cases? In other words, what’s the first place where I should look for errors?
This is app.js:
var app = angular.module('GalleryApp', ['ngRoute']);
app.config(function($routeProvider) {
$routeProvider
.when('/', {
controller: "HomeController",
templateUrl: "views/home.html"
})
.when('/photos/:id', {
controller: "PhotoController",
templateUrl: "views/photo.html"
})
.otherwise( {
redirectTo: '/'
});
});
This is photo.html:
<div class="photo">
<div class="container">
<img ng-src="{{ detail.url }}">
<h2 class="photo-title">{{photo.title}} </h2>
<p class="photo-author">{{photo.author}}</p>
<p class="photo-views">{{photo.views|number}}</p>
<p class="photo-upvotes">{{photo.upvotes|number}}</p>
<p class="photo-pubdate">{{photo.pubdate|date}}</p>
</div>
</div>
This is home.html
<div class="main">
<div class="container">
<h2>Recent Photos</h2>
<div class="row">
<div class="item col-md-4" ng-repeat="photo in photos">
<a href="#/photos/{{$index}}">
<img class="img-responsive" ng-src="{{ photo.url }}">
<p class="author">by {{ photo.author }}</p>
</a>
</div>
</div>
</div>
</div>
This is index.html
<!doctype html>
<html>
<head>
<link href="https://s3.amazonaws.com/codecademy-content/projects/bootstrap.min.css" rel="stylesheet" />
<link href='https://fonts.googleapis.com/css?family=Roboto:400,500,300' rel='stylesheet' type='text/css'>
<link href="css/main.css" rel="stylesheet" />
<!-- Include the core AngularJS library -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.min.js"></script>
<!-- Include the AngularJS routing library -->
<script src="https://code.angularjs.org/1.2.28/angular-route.min.js"></script>
</head>
<body ng-app="GalleryApp">
<div class="header">
<div ng-view></div>
<div class="container">
<a href="/#/">
<img src="img/logo.svg" width="80" height="80"> フ ォ ト フ ォ ト
</a>
</div>
</div>
<!-- Modules -->
<script src="js/app.js"></script>
<!-- Controllers -->
<script src="js/controllers/HomeController.js"></script>
<script src="js/controllers/PhotoController.js"></script>
<!-- Services -->
<script src="js/services/photos.js"></script>
</body>
</html>
HomeController.js
app.controller('HomeController', ['$scope', 'photos', function($scope, photos) {
photos.success(function(data) {
$scope.photos = data;
});
}]);
PhotoController.js
app.controller('PhotoController', ['$scope', 'photos', '$routeParams', function($scope, photos, $routeParams) {
photos.success(function(data) {
$scope.detail = data[$routeParams.id];
});
}]);
photos.js
app.factory('photos', ['$http', function($http) {
return $http.get('https://s3.amazonaws.com/codecademy-content/courses/ltp4/photos-api/photos.json')
.success(function(data) {
return data;
})
.error(function(data) {
return data;
});
}]);
Thanks much.