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})
}
}
出现跟随错误
paramMap 在类型“ActivatedRoute”上不存在
最佳答案
import 'rxjs/add/operator/switchMap';
将该导入添加到您的组件中...
关于angular - 尝试使用 paramMap 获取路由参数时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44974088/