2017-12-22 31 views
0

타이프 스크립트 또는 자바 스크립트 구문 문제가 있습니다. 누군가가 _ => this.log ...의 의미를 말해 줄 수 있습니까?hero.service.ts Angular v5 Tour of Heroes Tutorial에서 화살표 기능 앞에있는 밑줄 (_ =>)은 무엇입니까?

나는 거기에 화살표 함수로 전달되는 매개 변수 이름을 보는 데 익숙하다.

단순히 '매개 변수 없음'을 의미합니까?

참고 : 함수에서 사용하지 않을 매개 변수의 이름을 지정하는 개념이지만 https://angular.io/tutorial/toh-pt6#add-heroserviceupdatehero

/** PUT: update the hero on the server */ 
updateHero (hero: Hero): Observable<any> { 
    return this.http.put(this.heroesUrl, hero, httpOptions).pipe(
    tap(_ => this.log(`updated hero id=${hero.id}`)), 
    catchError(this.handleError<any>('updateHero')) 
); 
} 

답변

4

그것의 아무것도.

대신, 그들은 이런 식으로 작성된 것입니다 :

tap(() => this.log(`updated hero id=${hero.id}`)), 

당신이 더 읽고 싶다면, this post은 좋은 시작이다.

+0

지금 봅니다. tap (this.log ('updated hero id = $ {hero.id}'), –

+3

@OpTechMarketing'tap'은 함수가 반환 값이 아니라 호출 할 것으로 기대하기 때문에. – Li357