The problem with angular2 router running is running twice

I am having a problem with my angular2 router configuration Routes, which resolveruns twice, although it is defined only once.

Here is my definition Routes:

export const AppRoutes: Routes = [
  {path: '', component: HomeComponent},
  {
    path: 'dashboard',
    component: DashboardComponent,
    children: [
      {
        path: '',
        component: DashboardSummaryComponent,
        resolve: {
          userAccount: UserAccountResolve
        }
      },
      ...

When I go to the '/dashboard'following:

this.router.navigate(['/dashboard'])

The solution for DashboardSummaryComponent(i.e. UserAccountResolve) is executed twice ...

Can someone explain why? Is this to be expected?

edit 1 : It should be noted that UserAccountResolvethis is an http call . In addition, the first call (the one that fails) results in an error 401. (this does not seem to be relevant to the problem)

2. , , angular 2 , / ...

+4
2

Router 3.2.0 -

@ angular/router ~ 3.1.0

+1

​​ Angular 4.0

+1

Source: https://habr.com/ru/post/1652560/


All Articles