title: Is it possible to access $cookieStore from a service in angularjs?
body: <p>I'm trying to access $cookieStore (<code>$cookieStore.get("username")</code>) from inside a service like this:</p>
  
  <pre><code>var angServices = angular.module('angServices', ['ngResource', 'ngCookies']);
  angServices.factory('rsrUser', [ '$resource',
    function($resource, $cookieStore){
      var req = "/login"
      var timestamp = getMicrotime(true).toString();
      var username = $cookieStore.get("username");
      return $resource(baseURL + req, {}, {
        logIn: {method:'POST',
                isArray:false,
                headers:{
                    'X-MICROTIME': timestamp,
                    'X-USERNAME': username,
                    'X-HASH': getHMAC(timestamp, req)
                  }
              }
      });
    }]);
  </code></pre>
  
  <p>But this returns <code>TypeError: Cannot call method 'get' of undefined</code></p>
  
  <p>Am I doing something wrong or there is a better why to achieve this?</p>