Angular2 routing problems - zone related error No items in sequence

I searched quite a bit and did not find an answer that solved my problem. Therefore, I am posting this question.

My problem is very similar to this question. Angular 2.0.1 Router EmptyError: no items in sequence

But I could not solve it by adding pathMatch: 'full' ,.

I get an intermittent zonewaware error when I try to go from the list table (goes to the detailed view) below my module.

@NgModule({ imports: [ CommonModule, RouterModule.forChild([ { path: 'teams', component: TeamsListComponent, pathMatch: 'full', resolve: { TeamTemplate: TeamListTemplatesResolver }, canActivate: [AuthenticatedGuard] }, { path: 'teams/:id', component: TeamFormComponent, pathMatch: 'full', resolve: { team: TeamFormTeamResolver, resources: TeamFormResourcesResolver }, canActivate: [AuthenticatedGuard] } ]), 

My authGuard service has a canActivate method that returns boolean.

 public canActivate(): boolean { if (this.authService.isLoggedIn()) { return true; } this.router.navigate(['/logout', { redirect: location.pathname }]); return false; } 

And here's the error: Zone Warning

I could get the router event log using {enableTracing: true}:

 Router Event: NavigationStart Router Event: RoutesRecognized Router Event: GuardsCheckStart Router Event: GuardsCheckEnd Router Event: ResolveStart Router Event: NavigationError 
0
source share
1 answer

Thanks to everyone who looked at this issue. I got an answer to my question.

As I described, I have few resolvers when I go to the details page. One of these resolvers has logic to get the elements.

 public resolve(_route: ActivatedRouteSnapshot, _state: RouterStateSnapshot): Observable<T[]> { return this.service.browse({}).first(); } 

fooobar.com/questions/279838 / ... - As mentioned here, first () sends an error notification because there are no values. So I replaced it with take (1) and everything looks good.

As I mentioned in the comment above, it was good to know how to track events during routing. This is how I could trace it.

0
source

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


All Articles