Is there a way to remove DOM elements and Components using *NgIf or any Ng function?
I am working with a dropdown list that displays different forms based on the selection. The issue arises when a user changes the dropdown option, returns to the original option, and finds that the previous form data still exists instead of being cleared.
What would be the most effective method to delete all forms, variables, and the component itself when the dropdown selection changes?
Refer to the code snippet below,
<div class = "addressformtotal">
<div class = "addressblock">
<app-address-formatheader-form></app-address-formatheader-form>
<div *ngIf="formatMessage?.addressFormatDescription.includes('Standard')"><app-address-mailing-standard-form></app-address-mailing-standard-form></div>
<div *ngIf="formatMessage?.addressFormatDescription.includes('Military')"><app-address-mailing-military-form></app-address-mailing-military-form></div>
<div *ngIf="formatMessage?.addressFormatDescription.includes('Post')"><app-address-mailing-pobox-form></app-address-mailing-pobox-form></div>
<div *ngIf="formatMessage?.addressFormatDescription.includes('Free')"><app-address-free-form></app-address-free-form></div>
<div *ngIf="formatMessage?.addressFormatDescription.includes('Rural')"><app-address-mailing-rural-form></app-address-mailing-rural-form></div>
<div *ngIf="formatMessage?.addressFormatDescription.includes('International')"><app-address-mailing-international-form></app-address-mailing-international-form></div>
</div>