I am exploring ways to move an angular component, and I understand that it can be achieved through construction and destruction. For example, you can refer to this link: https://stackblitz.com/edit/angular-t3rxb3?file=src%2Fapp%2Fapp.component.html
However, I am facing a scenario where the components are already present in the DOM, and I simply want to relocate them within the DOM without creating new ones.
I have references to both source and destination class locations:
const dom: HTMLElement = this.el.nativeElement;
const elements1 = dom.querySelectorAll('.sourceClass');
const elements2 = dom.querySelectorAll('.destinationClass');
I have searched online but couldn't find any examples of moving elements directly without creating new ones. Additionally, I prefer not to use jQuery for this purpose.
If I were using jQuery, I would typically do something like:
jQuery('.destination').appendTo('.source');
This approach usually works well. Thanks!
Sean