Is it possible to inject Router using Injector.resolveAndCreate() ?
import {ExceptionHandler, Injectable, Inject,Injector} from 'angular2/core';
import {Router,ROUTER_PRIMARY_COMPONENT} from 'angular2/router';
@Injectable()
export class MyExceptionHandler implements ExceptionHandler{
constructor(public router: Router) { }
call(error, stackTrace = null, reason = null) {
console.log("ERROR >> " + error);
console.log("STACKTRACE >> " + stackTrace);
console.log("REASON >> " + reason);
let injector: any = Injector.resolveAndCreate([Router]);
let router: Router = injector.get(Router);
router.navigateByUrl('/error');
}
}
Getting EXCEPTION: Error during instantiation of Token RouterPrimaryComponent! (e -> Router -> RouteRegistry -> Token RouterPrimaryComponent).