Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lazyLoad and onBefore/onEnter for angular2/4/5? #60

Closed
schmitch opened this issue Dec 21, 2017 · 1 comment
Closed

lazyLoad and onBefore/onEnter for angular2/4/5? #60

schmitch opened this issue Dec 21, 2017 · 1 comment

Comments

@schmitch
Copy link

Hello, I'm using angular-hybrid successfully.

However now we wanted to create Loading Screens for our lazyLoaded Angular4 Modules. That somehow did not work.
We tried a global Transition Service on angularjs (however that is never called, no matter what the priority is):

   // angularjs code
    $transitions.onBefore({ to: 'a.**'}, (transition: Transition) => {
      // if authentication was successfull return true or Promise<true>
      // if it failed either return false / Promise<false> or a new Promise<state>
      console.log('Transition onBefore:', transition);
      transition.injector().get('Loading').show = true;
      return true;
    }, {priority: 1});

and also a onEnter hook directly on the lazyLoaded module:

// angular code
export function onEnterLazyLoad(transition: Transition) {
  console.log('onEnterLazyLoad')
  const loadingService = transition.injector().get<LoadingService>('LoadingService');
  loadingService.show = true;
  return true;
}
 {
    name: 'analysis.**',
    url: '/analysis',
    loadChildren: './lazy/analysis/analysis.module#AnalysisModule',
    onEnter: onEnterLazyLoad,
    data: { requiresAuth: false }
  },

However none works, only onSuccess/onError is called onError is called since the transition will actually be forwarded and then onSuccess is called. But under no circumstances is onEnter or onBefore called.

Any ideas?

@schmitch
Copy link
Author

nvm...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant