Simple Angular 2 question: why do I get a DI (dependency injection) error when I inject RouterStateSnapshot into my constructor in my Login Component? I'm trying to get the url prior to logging out, so I can pass that in for when a user logs back in (so it'll load their last visited component/page). This is proving more difficult than I expected. Even after importing it in and including RouterStateSnapshot in my constructor, I get a DI error. This is how I've set it up in my Login Component:
import { ActivatedRoute, ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
constructor(private router: Router,
private route: ActivatedRoute,
private authenticationService: AuthenticationService,
private alertService: AlertService,
private state: RouterStateSnapshot,
private authGuardService: AuthGuardService,
private idle: Idle)
{
What's the problem here? What am I missing about RouterStateSnapshot that's different than ActivatedRoute, ActivatedRouteSnapshot, etc - which I can import in and inject without problem? Why can't I inject RouterStateSnapshot in the same way?
By the way, I can use RouterStateSnapshot in my authGuardService without issue. It's being used in my canActivate() function - and returns the right result. So what's different in this situation? Why can't I use it here in my Login Component?