I've written that code on VSCODE, IONIC compiler V6.0.0, Angular V13.2.2:
export class OrderDetailNewPage implements OnInit {
public id:number;
tischContent = [
{
"anzahl": 0.5,
"groesse": 0.5,
"name": "test5",
"preis": 5.5,
"$token": "-N2mToYDj-i8ToErmaUj"
}
];
newTischContent =[];
neuerBezahlvorgang:[] = [];
constructor() { }
ngOnInit() {
}
pushBestellung(itemkey, indexOfElement){
console.log(this.neuerBezahlvorgang);
console.log(this.tischContent[0].anzahl);
this.neuerBezahlvorgang.push(this.tischContent[0]);
this.neuerBezahlvorgang[0].anzahl = Math.random();
console.log(this.tischContent[0].anzahl);
}
}
Here is the log - pushBestellung is triggered when every time you click on page
I want to push in the pushBestellung() function to push the content into the neuerBezahlvorgang[] array. but it changes the tischContent[] array too. WHY? Please Help.