How to load $cookies in Angular service?

Problem

I've defined an angular service in which I'd like to access some a cookie. Looking at the AngularJS docs it seems that $cookieStore is deprecated and that $cookies should be favored. Here is how my service looks:

'use strict';

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

lunchrServices.service('authService', ['$cookies', function ($cookies) {
    var user = $cookies.get('user') || null;

    this.login = function (userEmail) {
        user = userEmail;
        $cookies.put('user', userEmail)
    };
    this.logout = function () {
        user = null;
        $cookies.put('user', null);
    };
    this.currentUser = function(){
        return user;
    }

}]);

which errors out the on the $cookies.get('user') call with TypeError: undefined is not a function. However, if I change every instance of $cookies to $cookieStore it works perfectly (shown below):

'use strict';

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

lunchrServices.service('authService', ['$cookieStore', function ($cookieStore) {
    var user = $cookieStore.get('user') || null;

    this.login = function (userEmail) {
        user = userEmail;
        $cookieStore.put('user', userEmail)
    };
    this.logout = function () {
        user = null;
        $cookieStore.put('user', null);
    };
    this.currentUser = function(){
        return user;
    }

}]);

I'd like to use $cookies but can't figure out why it fails when $cookieStore doesn't. Any ideas?

Problem courtesy of: Paymahn Moghadasian

Solution

I assume it has something to do with this line in the docs

BREAKING CHANGE: $cookies no longer exposes properties that represent the current browser cookie values. Now you must use the get/put/remove/etc. methods as described below.

Which might mean that the previous version of angular didnt have those methods on $cookies.

Your version might be that older version.

Solution courtesy of: mkoryak

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.