So I've been skimming through many blogs/tutorials trying to figure this out but to no avail.
What I want is to be able to pass to @CanActivate()
functions which are supposed to figure out if the user is logged in. I have tried making a static function
static isUserInjector() {
return (next, prev) => Injector.resolveAndCreate([AuthService, HTTP_PROVIDERS]).get(AuthService).isUser();
}
inside my AuthService class so I just import it into the directive's .ts and call the static function but this seems a bit clumsy and I don't feel too good using this Injector because I suppose I was to bootstrap everything I'd need but I don't know how to get to it outside of my components. (I know only that you can get to the bootstrapped services by 'demanding' the in the constructor.
Is dependency injection a wrong pattern to go with @CanActivate?