angular - Inject Router using Injector.resolveAndCreate inside a class -


is possible inject router using injector.resolveandcreate() ?

import {exceptionhandler, injectable, inject,injector} 'angular2/core';  import {router,router_primary_component} '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: = 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).

sure, if use injector has router_providers registered, don't want a router instance the router instance - 1 used in application. need use same injector angular application uses.

this might looking redirect different component inside @canactivate in angular2


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -