The callback occurs after your second console.log call. Observables are asynchronous.
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
It all depends on what is calling your function. You could, for example, just return the observable. But that would require that the caller supports observavles. Angular 2's "CanActivatec might - I haven't looked into it.
Another Service is calling that method:
A simple Google search turned up a solution which seems to match exactly what you want to do:
https://github.com/angular/angular/issues/4112
--
Redirecting to another component when login is required.
This is the solution: