1

I know about this question here: AngularJS : Initialize service with asynchronous data which I have used in the past on 1.1 and 1.2.

But this requires you need to use old ngRoute module. I'm using ngNewRouter (available for angular 1.x) and don't have a resolve method for the routeProvider.

However it is possible to be done in components, not with the main controller:

//before navigation finishes, useful to load required data
appController.prototype.activate = function() {
  console.log ('loading data for the user');
  console.log (this.authService.requestCurrentUser());
  return this.authService.requestCurrentUser();
}

Still, the main controller it's not a component, so $componentLoaderProvider is not available.

How do I make the app wait for async data, without adding return this.authService.requestCurrentUser() to every component?

Thank you!

Community
  • 1
  • 1
Alexandru R
  • 8,560
  • 16
  • 64
  • 98
  • Hey! Checkout this resource: https://github.com/johnpapa/angular-styleguide#style-y080 it looks like you were going down the activate technique anyway, unless that's a coincidence. – Yeysides Jul 23 '15 at 20:28

0 Answers0