0

So I started out with AngularJS and I think it is amazing if you finally will master it, but for now I am really frustrated. I am trying to use routing. Everything works fine and there are no errors in the console, but Angular does not inject any content in my HTML :(. I am testing this on a localhost and the only thing angular does is adding a hash, like this: myAngularfolder/#/

Here is my code:

HTML

<!doctype html>

<html ng-app="app">

<head>

    <title>AngularJS</title>
    <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
    <script src="https://code.angularjs.org/1.3.9/angular.js"></script>
    <script src="https://code.angularjs.org/1.3.9/angular-route.js"></script>
    <script src="app.js"></script>

</head>

<body>

    <nav>
        <ul>
            <li><a href="index.html">Home</a>
            </li>
            <li><a href="about.html">Verhaals</a>
            </li>
            <li><a href="info.html">Info</a>
            </li>

        </ul>

    </nav>

    <div id="container" ng-view="">

    </div>

</body>

</html>

JS

  angular.module("app", ['ngRoute'])

  .config(function ($routeProvider) {
      $routeProvider
          .when('/', {
              templateURL: '/partials/products.html'
          })


  });

Any ideas?

1 Answer 1

2

Change

templateURL: '/partials/products.html'

to

templateUrl: '/partials/products.html'
Sign up to request clarification or add additional context in comments.

4 Comments

Yup this worked. Pff, how did I miss that? I like to write my code myself instead of copy pasting it from others so that I learn it the hard way and eventually better. I stil have to get used how angular works and how the syntax is written but I am on my way!
You are right, typing manually is more effective for remembering. Good luck!
I don't understand one thing: Why did it not give me an error in the console?
Because according to source code Angular just tolerate this, it just won't do anything if there is no template or templateUrl property defined (so no content for ngView directive).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.