Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular ngCookies

i can't inject ngCookies angular module into my project. Would you tell me why. I have done all instructions wich were in documentation. Write true code if it possible plz.

var mainApp =  angular.module('mainApp',["ngCookies","ngRoute"]).config(appConfig);

appConfig.$inject=['$routeProvider','$cookieStore','$cookies'];

function appConfig ($routeProvider){

  $routeProvider
    .when(
      '/add',
        {
          templateUrl:"view/add/index.html"
        }
    )
    .when(
      '/login',{
        templateUrl:'view/login/index.html',
        controller:'loginController'
      }
    )
    .otherwise({
      redirectTo:'/'
    })
};
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
<script src="assets/js/jquery/dist/jquery.js" charset="utf-8"></script>
<script src="assets/js/angular/angular.js" charset="utf-8"></script>
<script src="assets/js/angular-cookie/angular-cookie.js"></script>
<script src="assets/js/angular-route/angular-route.js" charset="utf-8"></script>
<script src="assets/js/angular-resource/angular-resource.js" charset="utf-8"></script>
<script src="assets/js/app/main.js" charset="utf-8"></script>
<script src="assets/js/app/controllers/loginController.js"></script>
<script src="assets/js/app/services/userLogin.js"></script>
  </head>
  <body>
    <div ng-app = "mainApp" class="main">
        <a id="add" href="#add">Дальше</a>
        <a href="#">Назад</a>
        <a href="#login">Логин</a>
        <div ng-view>

        </div>
    </div>
  </body>
</html>

Error like:

angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module mainApp due to: Error: [$injector:modulerr] Failed to instantiate module ngCookies due to: Error: [$injector:nomod] Module 'ngCookies' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.4.4/$injector/nomod?p0=ngCookies

like image 618
Юрий Шиповалов Avatar asked Oct 30 '22 20:10

Юрий Шиповалов


1 Answers

Would it help if you changed your script source by adding one 's' letter to the end of angular-cookie and before '.js', like below :

<script src="assets/js/angular-cookie/angular-cookies.js"></script>

Based on angular-ngcookies API, it's used like this:

<script src="angular-cookies.js">
like image 113
jyrkim Avatar answered Nov 15 '22 06:11

jyrkim