I am looking for a solid solution for the load order of my files of my Angular Meteor project.
I have the current folder structure:
[root]
client
lib
modules
directives
forms etc..
startup
styles
views
lib
collections
server
methods
publisher
My angular app is defined in client/lib/app.js
.
I created a service which would be client only and I put that in `client/lib/services/someService.js’
Now because it is a subfolder it will be loaded first and it will throw an error that angular is not defined. So, then I renamed app.js' to
00_app.js’ and the service to 01_someService.js
to force the order.
This didnt work in my case (probably because I bootstrap the app with onReady -> angular.bootstrap.document, [ 'appname' ]
)
I fixed it for now by putting the service in `client/modules/services/…’.
However, I rather put it in Lib cause modules is more for re-usable modules and widgets.
Also, when I want to define a service that is used server and client, would put it in [root]/lib/services..
. This would create the same load issue because Angular is not yet defined. I don’t want to use isClient or isServer in the service files.
I had another issue today where I add a filter to the [root]/lib/filters directory. It loads before the client/lib/app.js
is loaded. and throws the ‘Angular is not defined’ error. It is very annoying.
Is there an elegant solution for this?