I'm setting one array equalls to another
orders = [
{
'id': PROCESSING,
'displayName': 'Processing'
},
{
'id': SHIPPED,
'displayName': 'Shipped'
}
];
cloneOrders = [];
setOrders() {
this.orders.forEach((order: any) => {
this.cloneOrders = order;
});
}
But when I try to get values of 'cloneOrders' in another funtion it return an empty array
getOrders(status, minutes) {
this.cloneOrders .forEach((order: any) => {
console.log(order);
});
}
Both functions are in a same component. Please help me how to resolve this thanks.
this.cloneOrders.push(order);. Make surecloneOrdersis initialized.setOrdersmethod loops through theordersarray and assign current iteration item tocloneOrdersarray. So when the function returned, you'll have the last item ofordersstored incloneOrdersnot the complete array.