C
C
coderlex2016-07-01 19:28:21
typescript
coderlex, 2016-07-01 19:28:21

Why an access modifier on an argument in a constructor?

I came across this construction in the tutorials:
constructor(private heroService: HeroService) { }
At first I decided that the "private" access modifier in that place was a mistake, but I found that the tutorial would not compile without it.
I must have missed something when reading the typescript docs.
Tell me what it is, poke it into the docks, or at least tell me what it's called to drive it into Google?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2016-07-01
@coderlex

this is the shorthand syntax for declaring a field: www.typescriptlang.org/docs/handbook/classes.html , section Parameter properties.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question