Answers for "how to append element in array angular"

4

angular add object to array

import {Custom} from '../path/to/anyfile.ts'
.....
export class FormComponent implements OnInit {
 name: string;
 empoloyeeID : number;
 empList: Array<Custom> = [];
 constructor() {

 }

 ngOnInit() {
 }
 onEmpCreate(){
   //console.log(this.name,this.empoloyeeID);
   let customObj = new Custom();
   customObj.name = "something";
   customObj.employeeId = 12; 
   this.empList.push(customObj);
   this.name ="";
   this.empoloyeeID = 0; 
 }
}
Posted by: Guest on March-09-2020
1

how to append element in array angular

let object = []
object.push('string');
Posted by: Guest on October-19-2020

Code answers related to "how to append element in array angular"

Code answers related to "Javascript"

Browse Popular Code Answers by Language