This repository was archived by the owner on Dec 4, 2017. It is now read-only.
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
Test a routed component with parameters, example and aside don't match TOH code #3461
Open
Description
Test a routed component with parameters has a code snippet of subscribing to ActivatedRoute
params and using the "id" parameter to get a hero from a getHero
method.
ngOnInit(): void {
// get hero when `id` param changes
this.route.params.subscribe(p => this.getHero(p && p['id']));
}
The actual TOH code uses a switchMap
, calls the HeroService
, then subscribes to the returned hero.
ngOnInit(): void {
this.route.params
.switchMap((params: Params) => this.heroService.getHero(+params['id']))
.subscribe(hero => this.hero = hero);
}
The aside below this code snippet refers to a forEach
, a pluck
, and a catch
, none of which are used in the example or actual code.
All of this is confusing. The aside should probably be removed and the code snippet updated to match the latest TOH code.
Metadata
Metadata
Assignees
Labels
No labels