These are chat archives for Urigo/angular-meteor

26th
Feb 2016
mixersoft
@mixersoft
Feb 26 2016 14:53

I'm playing with angular-server and the angular-server-example app but I'm not sure i'm clear on the concept.

Is it possible to load an angular-server module on the server that does not exist in the client? I have collapsed the server code from the example to the following, but I can't find a way to load a module called todomvc.server

angular.module('todomvc.server',[])
  .service('Data0', function($http) {
    this.getData = function () {
      return $http.get('http://lorempixel.com/200/200/');
    };
  })


// angular.module('todomvc',['todomvc.server'])
angular.module('todomvc')
  .service('Data', function($http) {
    this.getData = function () {
      return $http.get('http://mockbin.org/bin/aae3f72e-ba4d-4d8a-b701-5545e8cfc9fe');
    };
  })
  .service('TodosManager', function (Todos) {
    this.addTodo = function (todo) {
      if (todo.title.length < 3) {
        throw new Meteor.Error(500, undefined, 'Title must be longer than 3 letters');
      }
      else {
        Todos.collection.insert(todo);
      }
    };

    Meteor.publish('todos', function () {
      return Todos.collection.find({});
    });
  })
  .config(function (ServerAPIProvider) {
    ServerAPIProvider.register('TodosManager');
  })
  .config(function(ServerAPIProvider, $injector) {
    if($injector.has('Data'))
      ServerAPIProvider.register('Data');
  });

angular.bootstrap(['todomvc']);
when I add this line on the server angular.module('todomvc',['todomvc.server']) I get
W20160226-16:54:52.745(2)? (STDERR) Error: [$injector:modulerr] Failed to instantiate module todomvc due to:
W20160226-16:54:52.745(2)? (STDERR) Error: [$injector:unpr] Unknown provider: ServerAPIProvider
if I try angular.module('todomvc',['todomvc.server', 'angular-meteor']) I get
Error: [$injector:unpr] Unknown provider: TodosProvider <- Todos <- TodosManager