gpt4 book ai didi

angular - 这在 Angular 文档中意味着什么?

转载 作者:搜寻专家 更新时间:2023-10-30 21:16:46 24 4
gpt4 key购买 nike

我目前正在学习 Angular 和 typescript,这部分 Angular 文档导致了问题。有人可以在下面示例中如何使用 => 的上下文中给出解释吗?我在网上搜索并找到了对 lambda 函数和返回类型的引用,但我找不到任何与 => 的使用相匹配的东西,就像它在这里使用的那样。

export class DashboardComponent implements OnInit {
heroes: Hero[] = [];
constructor(private heroService: HeroService) { }
ngOnInit() {
this.heroService.getHeroes()
.then(heroes => this.heroes = heroes.slice(1, 5));
}
gotoDetail() { /* not implemented yet */}
}

如果有人能帮助我理解这一点,我将不胜感激。

最佳答案

下方

this.heroService.getHeroes()
.then(heroes => this.heroes = heroes.slice(1, 5));

相当于:

var that = this;
this.heroService.getHeroes()
.then(function (heroes) {
return that.heroes = heroes.slice(1, 5));
});

关于angular - 这在 Angular 文档中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38582965/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com