Touqeer Touqeer - 1 year ago 183
AngularJS Question

Uncaught Error: [$injector:modulerr] while trying to use angular route

just try the following code and getting the error

<html lang="en">
<meta charset="UTF-8">
<title>Routing Intro</title>
<script src=""></script>
<script src=""></script>
<script scr="example.js"></script>

<body ng-app="mainApp">
<div ng-view></div>

here is my example.js file

var application = angular.module ('mainApp', ['ngRoute']);
application.config (function ($routeProvider){

.when('/', {
template : 'Welcome User!'

tempalte : 'Welcome to Another page'

otherwise ({
redirectTo : '/'

I am getting the following error
angular.js:4458 Uncaught Error: [$injector:modulerr]$injector/modulerr?p0=mainApp&p1=Error%3A…

Answer Source

Angular router is not a part of core angular module. You need to include it's javascript file:

<script src=""></script>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download