variable x is assigned to variable y in angular, whenever variable x changes y is also getting changed. how to prevent that?
ngOnInit() {
this.editFunction()
}
editFunction(){
for (let i = 0; i < this.editingData["tags"].length; i++) {
this.existingTagsDropDown.push(editingData["tags"][i].tag_id);
this.existingTagsChip.push({
value: editingData["tags"][i].tag_id,
viewValue: editingData["tags"][i].name,
});
}
this.existingTags = this.existingTagsChip;
}
addNewTags(){
for (let i = 0; i < this.selectedButtonOptions.length; i++) {
this.existingTagsChip.push({
value: this.selectedButtonOptions[i].value,
viewValue: this.selectedButtonOptions[i].viewValue,
});
}
}
existingTags is getting updated whenever existingTagsChip is updated. How to prevent that