Jay Tran

Jay Tran

  • NA
  • 3
  • 918

Type 'EmployeeService[]' is not assignable to type 'Employee[]'.

Sep 4 2021 8:25 AM

Hi all, 

I'm a newbie Typescript, I have below component:

export class EmployeeListComponent implements OnInit {

  employees:  Employee[];

  constructor(private employeeService: EmployeeService) { }

  ngOnInit(): void {

    this.getEmployee();

  }

  private getEmployee () {

    this.employeeService.getEmployeeList().subscribe(data => {

      this.employees = data ; //got error here

    });

  }

}

Below is error:

Type 'EmployeeService[]' is not assignable to type 'Employee[]'.
Type 'EmployeeService' is missing the following properties from type 'Employee': id, firstName, lastName, emailIdts(2322)

(property) EmployeeListComponent.employees: Employee[]

Thank you for any response.


Answers (1)