Reputation: 24659
I have got an issue with my configuration of angular2 router's Routes
whereby a resolve
is executed twice although defined only once.
Here is my Routes
definition:
export const AppRoutes: Routes = [
{path: '', component: HomeComponent},
{
path: 'dashboard',
component: DashboardComponent,
children: [
{
path: '',
component: DashboardSummaryComponent,
resolve: {
userAccount: UserAccountResolve
}
},
...
When I navigate to '/dashboard'
as follows:
this.router.navigate(['/dashboard'])
The resolve for DashboardSummaryComponent
(i.e. UserAccountResolve
) is executed twice...
Can someone please explain why? Is this to be expected?
edit 1: It must be noted that (this seems to be irrelevant to the issue)UserAccountResolve
is actually an http call. Also, the first call (the one that fails) results in a 401
error.
edit 2: The issue is probably related to the use of child components but I was not able to find relevant information in the angular 2 documentation about how resolves are dealt with by child/parent components...
Upvotes: 4
Views: 999
Reputation: 1316
Could be related to Router 3.2.0 - Providers instantiated twice
Try downgrading @angular/router to ~3.1.0
Upvotes: 1