1

I used older version of angularJS (1.1.4) for my test project (I want to learn angularJS). When I change angularJS script version to latest I got this error:

  Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.8/$injector/modulerr?p0=contactsManager&p1=…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.8%2Fangular.min.js%3A38%3A435)

I don't know what is causing this error... Does someone knows where's the problem?

UPDATE:

After removing .min from angularJS.js I got cleaner error message so here is it:

Error: [$injector:unpr] Unknown provider: $routeProvider
http://errors.angularjs.org/1.3.8/$injector/unpr?p0=%24routeProvide

Here is code:

JS:

//application.js
var app = angular.module('contactsManager', []);

app.config(function ($routeProvider) {
    $routeProvider
        .when('/contacts',
            {
                controller: 'ContactsController',
                templateUrl: './application/templates/contacts.html'
            })
        .when('/add-contact',
            {
                controller: 'ContactAddController',
                templateUrl: './application/templates/addContact.html'
            })
        .when('/edit-contact/:contactId',
            {
                controller: 'ContactEditController',
                templateUrl: './application/templates/editContact.html'
            })
        .when('/display-contact/:contactId',
            {
                controller: 'ContactDetailsController',
                templateUrl: './application/templates/displayContact.html'
            })
        .otherwise({ redirectTo: '/contacts' });
});

HTML:

<!DOCTYPE html>
<html data-ng-app="contactsManager">
<head>
    <title>Contacts</title>
    <link href="css/bootstrap.min.css" rel="stylesheet" />
    <link href="css/custom.css" rel="stylesheet" />
</head>
<body>

    <div class="navbar navbar-top">
        <div class="navbar-inner">
            <div class="container">
                <h2>Contacts</h2>
            </div>
        </div>
    </div>

    <div ng-view class="example-animate-container"
    ng-animate="{enter: 'example-enter', leave: 'example-leave'}"></div>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.7/angular-resource.min.js"></script>

    <script src="application/application.js"></script>
    <script src="application/controllers/controllers.js"></script>
    <script src="application/services/contactsService.js"></script>
</body>
</html>
3
  • In the future, remove .min from angular's script path to get a better error message. Commented Dec 22, 2014 at 20:53
  • also data-ng-app="contactsManager" to ng-app="contactsManager" Commented Dec 22, 2014 at 20:58
  • @sbaaaang I will do that to my app. Thank you for advise. Commented Dec 22, 2014 at 21:00

1 Answer 1

2

Newer versions of Angular have ngRoute as a separate module that you have to include in your project.

<script src="//code.angularjs.org/X.Y.Z/angular-route.js"></script>

https://docs.angularjs.org/api/ngRoute

And update your app initialization with an injection of ngRoute

var app = angular.module('contactsManager', ["ngRoute"]);
Sign up to request clarification or add additional context in comments.

5 Comments

I tried your solution and included angular-route.js . Now I got error this error: Error: [$injector:unpr] Unknown provider: $routeProvider
You also need to add a dependency of ngRoute: angular.module('contactsManager', ['ngRoute']);
@NewDev I need to update application.js with peace of code that you suggested?
I have manned to resolve issue with code that you suggested. I will mark your answer as a correct one. Thank you
@NewDev -- Ahh - forgot that part - added the ngRoute injection to the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.