William Robert
William Robert

Reputation: 63

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

Im getting this error when I try to include $cookie into my controller.

Anyone can explain to me what I did wrong?

I have angular-cookie.js in the index.html I have called 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 remove $cookies from here, no error.

Upvotes: 4

Views: 3438

Answers (1)

Prasad
Prasad

Reputation: 1600

I see that You are not Injecting Dependency Correctly.

It should be injected in the following way :-

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

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

});

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

I Found an Example For you http://plnkr.co/edit/bkhTxFsbHe6wMnapaDiY?p=preview

Sorry Dude it is in Some Different language ... But you can understand the Functionality.

Good Luck !!

Upvotes: 1

Related Questions