Gowtham Gowtham - 1 year ago 122
AngularJS Question

Angular Js Ng-Route

I have done a sample app with angular js and added a ng-route to load html inside it.I am getting "angular.js:3905 Uncaught Error: [$injector:modulerr] Failed to instantiate module plunker due to:Error: [$injector:unpr] Unknown provider: $routeProvider"

Here is my HTML script that i have added where i have added route script inside

<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<link data-require="bootstrap@3.3.0" data-semver="3.3.0" rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
<script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.28/angular.js" data-semver="1.2.28"></script>
<script data-require="angular-route@1.2.28" data-semver="1.2.28" src="https://code.angularjs.org/1.2.28/angular-route.js"></script>
<script data-require="jquery@2.2.0" data-semver="2.2.0" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script data-require="bootstrap@3.3.0" data-semver="3.3.0" src="https://netdna.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="app.js"></script>

I have created a live demo of the problem here

Lex Lex
Answer Source

You did not inject ngRoute in your app module. Change:

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


var app = angular.module('plunker', ['ngRoute']);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download