Using angularjs service ($cookies) in factory registered using couchpotato


I'm using angularjs with couchpotato for help with lazy loading. My question is how do I reference angularjs services like $http, $cookies in my service registered using couchpotato?

The normal angularjs way:

factory('MyService', function($cookies) { $cookies.message = "hello"; });

How do I do the above using angularjs with couchpotato.js? Below is my service with couchpotato:

define(['app'], function(app) { app.couchPotato.registerFactory(['myFactory', [ function() { var factory = {}; factory.registerCookie = function(){ $cookies.message = 'hello'; }; return factory; } ] ]); });

Of course the above wont work because I have no reference to $cookies in the factory.

Although the above example is specific to $cookies it is relevant to all angular services like $http, $rootScope etc.

Link to couchpotato.js: <a href="https://github.com/afterglowtech/angular-couchPotato" rel="nofollow">LINK</a>


This is off the top of my head, but something like this

define(['app'], function(app) { app.couchPotato.registerFactory(['myFactory', [ '$http', '$cookies', function($http, $cookies) { var factory = {}; factory.registerCookie = function(){ $cookies.message = 'hello'; }; return factory; } ] ]); });

You could also look at this sample <a href="https://github.com/afterglowtech/angular-couchPotato/blob/master/samples/components-demo/js/lazy/controllers/myCtrl1.js" rel="nofollow">https://github.com/afterglowtech/angular-couchPotato/blob/master/samples/components-demo/js/lazy/controllers/myCtrl1.js</a> which injects $scope


  • Controller inheritance with injection
  • Why are LSP violations in PHP sometimes fatal, and sometimes warnings?
  • Cannot implicitly convert type 'XXX' to 'T'
  • Cancelling an angular service promise
  • how to avoid the dependencies hell with unit test in angular 2+
  • Basic Authentication over redirection
  • Instanciate service on startup in Angular2
  • Updating Dojo provide
  • Should I or shouldn't I use the CachingConnectionFactory with hornetq 2.4.1
  • Get history of file changes from TFS to implement custom “blame”-behaviour of exceptions
  • SplFileObject error failed to open stream: No such file or directory
  • iOS: Detect app start via notification press
  • Sencha Touch 2.0 Controller refs attribute not working?
  • Meteor helpers not available in Angular template
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • NHibernate Validation Localization with S#arp Architecture
  • When to use `image` and when to use `Matrix` in Emgu CV?
  • How can I send an e-mail from a vbs script
  • Is calc() supported in html email?
  • What is the “return” in scheme?
  • req.body is undefined - nodejs
  • Accessing IRQ description array within a module and displaying action names
  • Modifying destination and filename of gulp-svg-sprite
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • How can I use Kendo UI with Razor?
  • Symfony2: How to get request parameter
  • Importing jscolor library in angular 2
  • Akka Routing: Reply's send to router ends up as dead letters
  • Circular dependency while pushing http interceptor
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Is there a mandatory requirement to switch app.yaml?
  • How to delete a row from a dynamic generate table using jquery?
  • using HTMLImports.whenReady not working in chrome
  • Getting Messege Twice Using IMvxMessenger
  • Authorize attributes not working in MVC 4
  • EntityFramework adding new object to nested object collection
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?