Angular factory into Meteor

Hi there,

I’m creating a full stack app in Meteor from a app created in Angular 1 in which I’ve got a factory sharing data between controllers like this:

angular.module('foodApp').factory('ClientInfo', function () {

    var client = {};
    client.numPlates = 15;

    return client;


I’m using angular-meteor for that but I’m not sure how to deal with this:

  • Which folder would be the best one to put this file?
  • Can I share my object in angular-meteor with this or do I have to use a different way to share info between controllers?


I put my angular code in imports/client/ followed by whatever method you want to use to organize your app code. Then you just have to make sure that it gets imported somewhere (your main app.js or the main file for the angular module that this factory belongs to is a good place).

Thanks for your response danryan.

Yes, I’ve got my scripts in that folder but I think I’ve not been clear: I’m creating my app according with angular-meteor tutorial. It’s Angular 1 but I’m using components and Typescript (for future migration to Angular 2). Do you know if the best way to share this info still being the factories or may I have to use another way?


You could also use client-side collections. Where you just define a mongo (minimongo) collection only on the client and harness all of its query capabilities. I’ve found that using angular-meteor my need for factories and services is greatly reduced because of this.

Hi seba,

Yes, I thought in that possibility as well but the use of factories is really quick to implement (and also I more used to it).
Anyway if is not a bad practique I’ll try with that.


Also, if you want to be more “Typescripty” you could define the service as a class and then use the module.service method instead of module.factory. The module.service method uses the new keyword to instantiate the service instance, i.e. it expects a class definition as its argument.

Mmm, that sounds good, thanks for the advice