I'm currently working on a project focused on providing detailed information about various vehicle components. Each component consists of specific descriptive fields. One feature I'm looking to implement is an "Add another component" button that will duplicate an existing div container with all its associated fields. Of course, the duplicated parent div should have a unique ID. Here's an example:
Within the component's HTML file:
<div id="component-outer">
<div class="component-inner">
Component Content....
</div>
</div>
<button type="button" (click)="clone()">Add Another Component</div>
In the component's TypeScript file:
export class AppComponent {
clone(){
Need to clone #component-outer div and append below the last instance
of that div, then append the div name on the cloned element.
}
}
While I typically use JavaScript/jQuery for cloning elements, I'm struggling to find the best approach to achieve exactly what I need in Angular. Would cloning be the appropriate method in this case?