Here are the model classes I am using:
import { Employee } from "./employee";
export interface Company {
id: number;
companyName: string;
dateOfEstablishment: Date;
companyInformation: string;
companyLogo: string;
employees: Employee[];
}
import { Company } from "./company";
import { EmployeeAddresses } from "./employeeAddresses";
import { EmployeeBankData } from "./employeeBankData";
import { EmployeeContacts } from "./employeeContacts";
import { EmployeeContracts } from "./employeeContracts";
import { EmployeeDependents } from "./employeeDependents";
import { EmployeeIdentityDocuments } from "./employeeIdentityDocuments";
import { EmployeePersonalDatas } from "./employeePersonalDatas";
export interface Employee {
id: number;
employeePersonalDatas: EmployeePersonalDatas;
employeeAddresses: EmployeeAddresses[];
employeeContacts: EmployeeContacts[];
employeeIdentityDocuments: EmployeeIdentityDocuments[];
employeeBankData: EmployeeBankData[];
employeeDependents: EmployeeDependents;
employeeCompany: Company;
}
public companies: Company[] = [];
public constructor(private companyService: CompanyService) { }
public ngOnInit(): void {
this.getCompanies();
}
public getCompanies() {
this.companyService.getCompanies().subscribe((companies) => {
this.companies = companies;
})
}
This component is for displaying a list of companies
private baseUrl: string = `${environment.baseUrl}`;
public constructor(private httpClient: HttpClient) {}
public getCompanies(): Observable<Company[]> {
return this.httpClient.get<Company[]>(this.baseUrl);
}
This corresponds to my service
<div *ngFor="let company of companies">
<app-company-card [company]="company" (selectionChange)="onItemSelected()"></app-company-card>
</div>
Can anyone assist me? It's for my internship and I'm facing an issue with an error message: Error trying to diff '[object Object]'. Only arrays and iterables are allowed