Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question