7
Comments
  • 1
    constructor(private http: HttpClient)

    Didn't know you can put private there. What does it do?
  • 1
    @nitwhiz That's syntax sugar for initialising class members (called "parameter properties").
    That in the picture is the same as having a private member http and setting it to the given http in the constructor.
  • 0
    @Benedikt On top of that you don't even need to explicitly provide it as a parameter to the constructor - you initialise it once in app.module.ts and Angular injects it automatically wherever you're using it.
  • 0
    @kamen The feature is not Angular specific but comes from Typescript.
  • 0
    I don't get the joke.
  • 3
    Jokes are like frogs, dissect them too much, and they die.
  • 1
    @mr-user the joke is the girl makes a sandwich without arguing ("Expected 1-2 arguments, but got 0")
  • 0
  • 1
    The reason this joke has such less upvotes cause users in this community have no concept of "your girl"
  • 0
    @Benedikt Thought so, thx.

    Nice. I would flip the fucken table if I encounter this in code but at the same time I'd totally do it myself.
  • 0
    @VaderNT lol that's actually quite funny.
  • 0
    @Benedikt I know, but Angular still does some magic in terms of injecting stuff that you might want to use (i.e. HttpClient like here) without requiring you to pass it to the constructor by yourself (in fact one would hardly ever create a component by calling its constructor manually).
Add Comment