Touqeer Touqeer - 4 months ago 40
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…


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

<script src=""></script>