brent
brent

Reputation: 502

angular ngCookies Error: [$injector:modulerr]

In my angular app I installed angular-cookies => npm install angular-cookies.

I add the following to my angular module:

var app = angular.module('app', ['ngCookies','ngResource', 'ngRoute'])
  .config(function($routeProvider, $locationProvider, $httpProvider, $cookies) {

I get the following error when I try to launch:

Failed to instantiate module app due to: Error: [$injector:modulerr] http://errors.angularjs.org/1.3.11/$injector/modulerr?p0=...) at https://localhost:3000/javascripts/angular.min.js:6:417 ......

I am not sure why my injection is failing

Upvotes: 3

Views: 3492

Answers (1)

captain_rillette
captain_rillette

Reputation: 171

I solved the same problem this morning,

Try to get the same api version of angular and angular-cookies, your angular version is 1.3.11 and your angular-cookies is 1.4.4.

This link is the latest stable version of all components (1.5.8)

A part of my app.js :

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

app.controller('loginFormController', ['$scope', '$log', '$http','$cookies', function($scope, $log, $http, $cookies) {
//Your code here
}]);

A part of my index.html :

<!DOCTYPE html>
<html lang="fr" ng-app="app">
    <head>
        <meta charset="utf-8" />
        <title>App| Login</title>
        <link rel="stylesheet" href="../assets/css/style.css">
        <link rel="stylesheet" href="../assets/css/login.css">
        <script src="../assets/angular.min.js"></script>
        <script src="../assets/angular-cookies.js"></script>
        <script src="../assets/jquery-3.1.1.min.js"></script>
        <script src="../controller/app.js"></script>
    </head>
    <body ng-controller="loginFormController as login">
    </body>
</html>

I hope it will help you

Upvotes: 2

Related Questions