-4

This is the code

This is the error

this is the GitHub code that I coded as it is watching his youtube video

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Welcome to stackoverflow. Please don't post code as links to images, but as text with proper code tags. – M. Deinum May 23 '22 at 08:41

1 Answers1

1

The error is pretty clear so I can answer:

constructor(
  employeeService: EmployeeService
) { ... }

When you write this, the scope of your variable is only the constructor itself.

To declare it as a class-scoped variable, you have to set it :


private employeeService: EmployeeService;

constructor(
  employeeService: EmployeeService
) {
  this.employeeService = employeeService;
}

You can also use typescript's shortcut feature like such :

constructor(
  private employeeService: EmployeeService
) { ... }

Which will achieve the same result.

halfer
  • 19,824
  • 17
  • 99
  • 186