I am having a strange issue since I updated to angular's latest 
router(3.0.0-beta.2)

If I execute this code
 this._router.navigate(['/login']);

anywhere in my app it works fine except when I initially load the app and 
try to make a redirect.
No error is thrown, it just simply does not redirect.

Here is my code:

main.ts file:

bootstrap(AppComponent, [APP_ROUTER_PROVIDERS, HTTP_PROVIDERS, 
ApplicationConfiguration, provide(Http, {
  useFactory: (xhrBackend: XHRBackend, requestOptions: RequestOptions, 
router: Router, appConfig: ApplicationConfiguration) => new HttpServiceLayer
(xhrBackend, requestOptions, router, appConfig),
  deps: [XHRBackend, RequestOptions, Router, ApplicationConfiguration]
})]);

app.component.ts:

export class AppComponent {
constructor(private appConfig: ApplicationConfiguration,  private _router: 
Router) {
if (!this.appConfig.isUserLoggedIn()) {
      this._router.navigate(['/login']);
    }
 }
}

export const routes: RouterConfig = [
  { path: 'login', component: LogInComponent },
  { path: 'dashboard', component: DashboardComponent },
  { path: '', redirectTo: '/dashboard', pathMatch: 'full' }
];

export const APP_ROUTER_PROVIDERS = [
  provideRouter(routes)
];

It may be that I am not doing something correct, but this code used to work 
before the update.

Does any body know why the router would not redirect the user to the log in 
page?

Any help is appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to