I am struggling with the code below:
export class FormComponent implements OnInit {
name: string;
empoloyeeID : number;
empList: Array<{name: string, empoloyeeID: number}> = [];
constructor() {
}
ngOnInit() {
}
onEmpCreate(){
console.log(this.name,this.empoloyeeID);
this.empList.push.apply(this.name,this.empoloyeeID);
this.name ="";
this.empoloyeeID = 0;
}
}
I encountered an error while running this code:
CreateListFromArrayLike called on non-object
Is there a way to create a custom class and use object list instead of defining an array in this code?
Thank you