jeudi 4 avril 2019

Accessing properties of object inside other object class

I have 2 object classes in my angular7 application that are filled with data - employee and company (data is received through web api from database). Employee has fields - emp_id, name, surname and company object. Company has - c_id, company_name, phone. I can display employee - emp_id, name and surname data in table using "name" and "surname", but when trying to display employee company, the result displayed is "[object Object]", but I want to display company_name.

If data from web api is viewed from program like postman, the company object is correctly displayed inside employee object.

I have tried using these combinations to access company name - "company.company_name", "company{company_name}", "company(company_name)", but none of this works.

Here are my classes in angular

export interface employee
{
emp_id: number;
name: string;
surname: string;
company: Company;
}

export interface company
{
c_id: number;
company_name: string;
phone: string;
}




Aucun commentaire:

Enregistrer un commentaire