TWFPSP TWFPSP - 1 year ago 125
AngularJS Question

Can't inject ngRoute dependency in Angular

I can't seem to create a simple angular route in my current application, since it handles me the following error: Uncaught Error: [$injector:modulerr]

I have already injected ngRoute as a dependency in my module, as well as added the angular-route.js script in my html file. My current Angular version is 1.2.25, so it's the angular-route script.


<html lang="en">
<meta charset="UTF-8">
<title>ACME App</title>
<script src=""></script>
<script src=""></script>
<script src="js/controllers.js"></script>
<body ng-app="init">
<a ng-href="#main">sup</a>


var app = angular.module("init", ["ngRoute"]);

app.config('$routeProvider', function($routeProvider) {
.when("/", {
templateUrl : "templates/main.html"


<h1>Main Page</h1>

Answer Source

I think that you missed [ ]

app.config(['$routeProvider', function($routeProvider) {
    .when("/", {
        templateUrl : "templates/main.html"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download