FAQ: Routing - Routing II

This community-built FAQ covers the “Routing II” exercise from the lesson “Routing”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn AngularJS 1.X

FAQs on the exercise Routing II

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi there,

New to codecademy and just working through the Angular.js training. I’m on Routing II and the web browser section doesn’t seem to be showing what it’s meant to. I’m making the various code changes and there are no errors coming back, but all I can see is this blank screen with some randome characters on it. It doesn’t change at all, throughout the section. Anything you could to help?

Thank,
Marc

Please post your code from index.html and app.js.

Hi, thanks very much for your reply . Hopefully i’ve used the correct format, to post the code.
Kind regards,
Marc

<!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"> &#12501; &#65387; &#12488; &#12501; &#65387; &#12488;
        </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>
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: '/'
  	});
});

Ok, that is something I can work with :slight_smile: There are two problems in your code.

First one, in app.js you have to change templateURL to templateUrl (in both routes).

Ok, now run your code. You should see different output, but it still does not look quite right. The logo (with text that means “Photo” in Japanese :slight_smile:) was pushed to the bottom of the page. This tells us that something is wrong with our ng-view in index.html.

Previous exercise, step one:

In index.html under the .header section, type in the code exactly as you see here:
<div ng-view></div>

When we use words like “below”, “under” in reference to the blocks of code I am lost. And it looks like I am not the only one having this problem :slight_smile: In this step they wanted you to place this code below the whole header block, take a look:

<div class="header">
  <div class="container">
    <a href="/#/">
      <img src="img/logo.svg" width="80" height="80"> &#12501; &#65387; &#12488; &#12501; &#65387; &#12488;
    </a>
  </div>
</div>
<div ng-view></div>

Thanks ever so much. I’ve made those changes now and it’s allowed me to complete the course :slight_smile:

1 Like

You’re very welcome :slight_smile: