I am facing an issue in Angular 4 where I am attempting to retrieve details from a specific user when clicking on the 'user link profile'.
However, I am unable to subscribe to my function because the return value of switchMap is AnonymousSubject instead of Observable:
ngOnInit() {
this.route.paramMap.switchMap((params: ParamMap) => this.getHero(+params.get('id')))
.subscribe(hero => {
this.hero = hero;
})
}
Below is the getHero function being used:
getHero(id: number) {
return this.getHeroes().find(hero=>hero.id===id);
}
The getHeroes() function retrieves simple objects of JSON data containing details about heroes such as their ID and name.
Appreciate any help or suggestions!