In AngularJS route set up, I could use the "resolveRedirectTo" facility to calculate a value using an injected service, which I could then use in the redirect URL, e.g.
myModule.config(['$routeProvider', function($routeProvider) { $routeProvider
.when( '/user/:userId', {template:'<my-component>'} )
.otherwise( {resolveRedirectTo: ['MyService', function(MyService){
return '/user/' + MyService.getDefaultUserID();}]
});
}]);
How can I do the same in Angular 2 (or Angular 4, etc)? Specifically, how to invoke an injected service so that I can dynamically create the URL to redirect to.