0

just try the following code and getting the error

<html lang="en"> 
<head>
<meta charset="UTF-8">
<title>Routing Intro</title>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-resource.min.js"></script>
    <script scr="example.js"></script>

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

here is my example.js file

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

$routeProvider
.when('/', {
    template : 'Welcome User!'
})

.when('/anotherPage',{
    tempalte : 'Welcome to Another page'
})

otherwise ({
    redirectTo : '/'
});
});

I am getting the following error angular.js:4458 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=mainApp&p1=Error%3A…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A19%3A463)

Touqeer
  • 77
  • 9
  • Possible duplicate of [Angular 1.4.5 : Uncaught Error: \[$injector:modulerr\] ngRoute](http://stackoverflow.com/questions/32572471/angular-1-4-5-uncaught-error-injectormodulerr-ngroute) – Mogsdad Jun 28 '16 at 19:52

1 Answers1

1

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

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.min.js"></script>
Ron Dadon
  • 2,666
  • 1
  • 13
  • 27