Les Paul Les Paul - 4 months ago 70
TypeScript Question

Angular2 Typescript "= () =>"

Easy question for someone to answer, what happens in this typescript function?

getTweetCount = () => this.data.totalCount;


data.totalCount is of type number from a service.

Answer

getTweetCount = () => this.data.totalCount;

You are creating an arrow function that returns this.data.totalCount.

More

Arrow functions : https://basarat.gitbooks.io/typescript/content/docs/arrow-functions.html