0

I have a child route history and i get an empty error.

Uncaught (in promise): EmptyError: no elements in sequence EmptyError: no elements in sequence

enter image description here

Here is my code:

{path: 'calories', pathMatch: 'full', component: CaloriesComponent, canActivate: [UserService], children: [
    {path: 'history', pathMatch: 'full', component: CaloriesHistoryComponent, canActivate: [UserService]}
  ]},
  • Your UserService is probably incorrect, and completes without emitting true or false. Why the `pathMatch: 'full'`, BTW? – JB Nizet Dec 18 '17 at 20:28
  • `canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { return this.isAuth().then( response => { if (response.success) { this._logged_user.next(new User(response.data)); return true; }else { this._logged_user.next(null); this.router.navigate(['/signin']); return false; } } ); } ` – George Sendrea Dec 18 '17 at 20:32
  • Why are you setting the same can activate on the child route? The parent route authguard will propagate to all children – Hugo Noro Dec 18 '17 at 21:06

2 Answers2

1

This error happens when using RxJS 5.5.3 with angular (version 4/5), so just skip RxJS 5.5.3, and use RxJS 5.5.4 by adding "rxjs": "^5.5.4" to your project package.json

Ajay Reddy
  • 1,475
  • 1
  • 16
  • 20
-1

I don't see any issues with your code. I searched the error use gave and I found this post about it. Seems to be relevant to your question. I hope this helps.

Here is the post

Sericet
  • 21
  • 6