title: How to use $cookie in factory/service in angular js?
body: <p>In one of the app i am building, i want to use $cookie in service(.factory(...)).</p>
  
  <p>When i use the $cookie i get $injector/module error. Can any one help me in this regard ?</p>
  
  <p>Here is the code i have written.</p>
  
  <pre><code>app.factory("AuthenticationService", function($location,$cookies,setUserCreds) 
  {
  
   return {
  
    login: function(credentials) {
      if (credentials.username == "MyName" || credentials.password == "admin") {
          $cookies.put("userName",credentials.username);          
          $location.path('/home');
  
     } 
  }}});
  </code></pre>