Error: [$ injector: unpr] http://errors.angularjs.org/1.3.5/$injector/unpr?p0=

I get this error when I try to include $ cookie in my controller.

Can anyone explain to me what I did wrong?

I have angular-cookie.js in index.html I called the ngcookies module in config.js In my controller I have

    angular
    .module('homer')
    .controller('authCtrl', authCtrl)
function authCtrl($scope, $rootScope, $location, $cookies, $http, sweetAlert, Data) {
debugger;

If I delete $ cookie here, there is no error.

+4
source share
1 answer

I see that you are injecting addiction incorrectly.

It should be entered as follows: -

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

MyModule.controller('MyController', function($scope, $cookies, $window, $cookieStore) {
  $cookies.cookieSimple = 'Simple Cookie ';

});

Please note: - https://docs.angularjs.org/api/ngCookies and https://github.com/angular/bower-angular-cookies

http://plnkr.co/edit/bkhTxFsbHe6wMnapaDiY?p=preview

, Dude ... .

!!

+1

All Articles