Why does when it is the following code:
for (var i = 0; i < 3; i++) {
this.arr.push({
id: 2,
firstName: "FirstName",
lastName: "LastName",
emailId: "lastname_firstname@yahoo.com",
sex: "Female",
isFilipino: true,
maritalStatus: "Single"
});
};
```````````````````````````````````````````````````````````````````````
The following code this.arr3 return values:
````````````````````````````````````````````````````````````````````````````````````
this.arr.forEach((a: any) => {
this.arr3.push(a);
});
```````````````````````````````````````````````````````````````````````````````````````
But when in the following code:
```````````````````````````````````````````````````````````````````````````````````````
this.employeeService.getEmployeesList().subscribe(data => {
for (var i = 0; i < 3; i++) {
this.arr.push({
id: 2,
firstName: "FirstName",
lastName: "LastName",
emailId: "lastname_firstname@yahoo.com",
sex: "Female",
isFilipino: true,
maritalStatus: "Single"
});
}
}
);
The following code this.arr3 return as empty:
this.arr.forEach((a: any) => {
this.arr3.push(a);
});
``````````````````````````````````````````````````````````````````````````````````````````
Thanks in advance.