marcoslin / angularAMD

Facilitate use of RequireJS in AngularJS
http://marcoslin.github.io/angularAMD
MIT License
734 stars 171 forks source link

bootstrap angular with async data #130

Closed robson-gilli closed 9 years ago

robson-gilli commented 9 years ago

Hello.

I'm using angular+angularAMD+requirejs in my project, and I need to load data asynchronously from the server in order to configure my app. I've been searching for alternatives and it seems that this post could be a way to go (http://stackoverflow.com/questions/16286605/initialize-angularjs-service-with-asynchronous-data).

The problem is that I'm facing some dificulties trying to fit the approaches in the article above together with the behavior of angularAMD.

Did anyone have to solve that same issue? Is there a way to do it with angularAMD?

Thanks Robson

tinquang commented 9 years ago

I have the same problem, does anyone have the answer ?

Thanks.

robson-gilli commented 9 years ago

I ended up doing the following:

  1. Started using ui-router(https://github.com/angular-ui/ui-router) instead of ngRoute;
  2. Created a root abstract state, parent of all other states;
  3. Used the resolve section of the root state to load all data needed before any controller get instantiated
tinquang commented 9 years ago

Hi Robson, I used ui-router already, but I don't create root abstract state. I hope there is another way to work around this issue. Thanks for your solution.

Quang Nguyen