현재 Angular2 및 타이프 스크립트를 배우고 있으며 각도 2 설명서의이 부분이 문제의 원인입니다. 누군가 아래의 예에서 어떻게 사용되는지에 대한 설명에서 => 설명을 줄 수 있습니까? 나는 온라인으로 검색했고 람다 함수와 리턴 타입에 대한 참조를 발견했다. 그러나 여기에 사용 된 것과 같은 => 사용과 일치하는 것을 찾을 수 없었다.이것은 angular2 문서에서 무엇을 의미합니까?
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 */}
}
누구나 내가이 점을 이해하도록 도울 수 있다면 정말 고맙겠습니다.
var that = this;
this.heroService.getHeroes()
.then(function (heroes) {
return that.heroes = heroes.slice(1, 5));
});
사용해보기 : https://basarat.gitbooks.io/typescript/content/docs/arrow-functions.html –