netanelgilad / polyfill-angular-server

0 stars 1 forks source link

Injection error in angular-server-example #4

Closed 6gsaifulislam closed 9 years ago

6gsaifulislam commented 9 years ago

I am have trouble with using angular-server so I tried using the example version - but I am running into the following problem:

Error: [$injector:unpr] Unknown provider: DataProvider <- Data <- MainController

So basically the client is not getting the api service defined in ServerAPIProvider.register('Data');

Steps taken: 1: created new meteor folder. 2 added packages urigo:angular and etanelgilad:angular-server 3 removed default js html and css files. 4 Copied the folders client, lib, model and server from angular-server-example github.

So basically the Angular client does not know about the Data and TodosManager services

netanelgilad commented 9 years ago

Can you share your code? i'll have a look...

6gsaifulislam commented 9 years ago

Here is a link to zip file on my OneDrive:

http://1drv.ms/1JbEkcy

netanelgilad commented 9 years ago

You just need to use the 0.9.0 alpha version of urigo:angular and everything will work :) change the version in your versions file to 0.9.0-alpha.5.

6gsaifulislam commented 9 years ago

Thanks very much - it worked a treat!

6gsaifulislam commented 9 years ago

Sorry to be a pain in the neck: could you check that version 0.9.0-alpha.5 is ok with ng material - I have been trying to get my version to work and have found that the problem occurs when ng material is injected into lib/app.js

Sorry I am wrong the problem is I cannot add any packages i.e. ui.router not working either!

image

netanelgilad commented 9 years ago

Since lib/app.js is shared in server and client code, loading client libraries on the server is not going to work. Change your app.js like so:

var deps = ['angular-meteor'];
if (Meteor.isClient) {
  deps.push('ng-material');
}
else {
  deps.push(......);
}
var app = angular.module('myApp', deps);

should make it work...

6gsaifulislam commented 9 years ago

Thanks very much - I was going round in circles putting lib/app in the main folder or in the client folder and beginning to wonder which was right.

Looking at the example code provided var deps = ['angular-meteor']; ... does that mean the angular server side can have libraries loaded, and how is debugging going to work on the server? Angular can be very tricky to get right - is there the ability to debug in run mode?

netanelgilad commented 9 years ago

Yeah you can debug the server side just like any meteor app. Here a SO question with explanations: http://stackoverflow.com/questions/11034941/meteor-debug-on-server-side

6gsaifulislam commented 9 years ago

Many thanks it looks good, I hope I don't have to do much debugging