【发布时间】:2021-04-07 16:56:30
【问题描述】:
当我在 Angular 文档中做 Angular Heroes 教程时。我收到一个错误
对象可能是“空”。
getHero(): void {
const id = +this.route.snapshot.paramMap.get('id');
this.heroService.getHero(id)
.subscribe(hero => this.hero = hero);
}
在 hero-detail.component.ts
完整代码链接hero-detail component
我在 config.json 中看到了很多答案,以至于将其设为假。 我需要有关如何解决此问题的帮助,但不要压制它。
提前致谢。
【问题讨论】:
标签: angular typescript angular-routing