Reputation: 485
export class HeroDetailComponent {
heroes;
constructor(private route: ActivatedRoute, private router: Router, private hs : HeroService){
}
ngOnInit(){
this.route.paramMap
.switchMap((params : ParamMap) =>
this.hs.getHeroes(params.get('id')))
.subscribe((heroes) => {
console.log("checking for heroes n subscribe",heroes);
this.heroes = heroes})
}
}
Getting following error
paramMap doesn't exist on type 'ActivatedRoute'
Upvotes: 3
Views: 3954
Reputation: 1
ParamMap has been introduced in 4.0.0-rc.6 version. Make sure you have at-least Angular 4 version.
Upvotes: 0
Reputation: 3400
Make sure you're importing ParamMap from @angular/router
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
Upvotes: 0
Reputation: 23
import 'rxjs/add/operator/switchMap';
add that import to your component...
Upvotes: 1
Reputation: 210
not too sure if this will help but you may want to try following:
hopefully this works for you. i had the same issue and if i never remember wrongly, i did the above and ParamMap exist after.
Upvotes: 0
Reputation: 9341
In your switchmap
paramMap type is wrong.
It should be
.switchMap((params : ParamMap) =>
Upvotes: 0