Great! A gallery of images shows up. How does it work?
- In app.js inside the
app.config() method, we use Angular's
$routeProvider to define the application routes.
- We used
.when() to map the URL
/ to to the controller
HomeController and the template
HomeController uses the service js/services/photos.js to fetch the array of all photos from https://s3.amazonaws.com/codecademy-content/courses/ltp4/photos-api/photos.json and stores it into
ng-repeat to loop through each item in the
photos array and display each photo.
- Otherwise if a user accidentally visits a URL other than
/, we just redirect to
- Now when a user visits
/, a view will be constructed by injecting
home.html into the
<div ng-view></div> in index.html.