I want to use Salary Type for salaries
class variable. how can i do it ? please help me
export class Employee {
id: string = "";
birth_date: string = "";
emp_no: string = "";
first_name: string = "";
last_name: string = "";
gender: string = "";
hire_date: string = "";
salaries: Salary = "";
constructor() {
this.salaries = new Salary;
}
}
export class Salary {
id: string = "";
emp_no: string = "";
salary: string = "";
rom_date: string = "";
to_date: string = "";
}
CodePudding user response:
there are two errors: salaries: Salary = null;
and this.salaries = new Salary();
in many cases you don't need a class but you can use a Type or an interface, i.e.
export interface Employee {
id?: string;
birth_date?: string;
emp_no?: string;
first_name?: string;
last_name?: string;
gender?: string;
hire_date?: string;
salaries?: Salary;
}
export interface Salary {
id?: string;
emp_no?: string;
salary?: string;
rom_date?: string;
to_date?: string;
}