$routeProvider does not work - Angularjs

Asked

Viewed 105 times

1

I’m trying to do something simple on Plunker which is to load the contents of home html. in index.html, however, is giving error.

Before it was not working even this line of code(when put the ngRoute but after adding the required lib worked):

var app = angular.module('plunker', ['ngRoute']);  

Now it’s these lines that are giving trouble:

app.config(['$routeProvider', function($routeProvider){
  $routeProvider.
    when('/home', {
      templareUrl: 'home.html'
    })
}]);

The goal is simple: to call home.html content in index.html

Follow the link: https://plnkr.co/edit/baHrKC2l0S8nCaHoacsb

1 answer

1


You are using the version 1.5.11 angular, but is using the version 1.6.6 angular-route. Work with the same versions to avoid problems. Also, use:

<a href="#home">Go to home</a>

instead of:

<a href="\home">Go to home</a>

...because this second will try to load the file home.html in https://run.plnkr.co/home instead of searching inside your project (otherwise it might even work in a real project, because the file could exist on your site).

Also, in the archive app.js you wrote templareUrl instead of templateUrl (a silly but boring mistake to realize).

Follows plunker up-to-date and functioning.

  • Very important to highlight the issue of the same versions!!! And also stressed the error in the syntax of templateUrl and that in fact I made a mistake! Perfect! Very grateful!!!

  • 1

    @Wesleyredfield the issue of the version I already broke my head a lot because of it. As for the error in the templateUrl is normal, this is solved by increasing the dose of coffee. You are welcome!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.