0

I am trying to figure out why I have this error:

Uncaught Error: [$injector:modulerr]

I have the following code in index.html

<!DOCTYPE html> <html ng-app="MainApp"> <head> <meta charset="utf-8"> <link rel='stylesheet' type='text/css' href='core/sty.css'> <script src="core/CS/ang/angular.min.js"></script> <script src="core/CS/ang/angular-resource.min.js"></script> <script src="core/CS/ang/angular-route.min.js"></script> </head> <body> <div id="header-cont"> <div id="header"> <ul style="list-style:none;"> <li style="display:inline;float:left;"><font style="font-size:38px;top:-5px;left:-1px;position:fixed;">title</font></li> <li class="menu">News</li> <li class="menu"><ul class="sub-menu"> <a href="/admin/login"><li class="SMoption">1 First login</li></a> <a href="/admin/register"><li class="SMoption">2 Duble register</li></a> </ul>account</li> </ul> </div> </div> <ng-view></ng-view> <script src="core/CS/mainscript.js"></script> <script src="core/CS/config.js"></script> <script src="core/CS/controllers.js"></script> <script src="core/CS/modules.js"></script> </body> </html> 



The mainscript.js

'use strict'; var appv = angular.module("MainApp", ['ngRoute','ngResource']); 


And config.js

'use strict'; appv.config(function($routeProvider) { $routeProvider. when('/', { //controller: 'HomeController', templateUrl: 'views/home.html' }). when('/page/:pgId', { //controller: 'PageController', templateUrl: 'views/page.html' }). when('/article/:pgId/:artId', { //controller: 'ArticleController', templateUrl: 'views/article.html' }). when('/admin/:adCode', { //controller: 'AdminController', templateUrl: 'views/admin.html' }). otherwise({templateUrl: 'views/home.html'}); $locationProvider.html5Mode(true); }); 




As you can see I have included the ng-route.js, ngRoute module, but something doesn't work...

2
  • put the script tag for ngroute and ngresource .js files above the angular's js file and all of them above your scripts Commented Dec 13, 2014 at 9:49
  • you can check my answer stackoverflow.com/questions/27456033/… Commented Dec 13, 2014 at 10:48

2 Answers 2

1

you enable the html5 mode by adding $locationProvider.html5Mode(true); but you didn't inject the $locationProvider provider into the config function, adding that will solve the problem :)

appv.config(function($routeProvider, $locationProvider ) { ......... 
Sign up to request clarification or add additional context in comments.

Comments

1

You need to include $locationProvider as a dependency in your config function like this:

'use strict'; appv.config(function($routeProvider, $locationProvider) { $locationProvider.html5Mode(true); $routeProvider. when('/', { //controller: 'HomeController', templateUrl: 'views/home.html' }). when('/page/:pgId', { //controller: 'PageController', templateUrl: 'views/page.html' }). when('/article/:pgId/:artId', { //controller: 'ArticleController', templateUrl: 'views/article.html' }). when('/admin/:adCode', { //controller: 'AdminController', templateUrl: 'views/admin.html' }). otherwise({templateUrl: 'views/home.html'}); }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.