Angular Reactive Forms: Unexpected Behavior with FormGroup Reset and Value Changes
I'm not sure how to approach I tried several approaches but none seem to work... I am experiencing an issue with Angular Reactive Forms where calling `reset()` on a `FormGroup` does not seem to clear the values of the form controls as expected. I have a form that contains a `FormGroup` for user details, and I am trying to reset it after submission. However, when I reset the form, the form controls retain their previous values instead of being cleared. Hereβs a simplified version of my form setup: ```typescript import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; @Component({ selector: 'app-user-form', templateUrl: './user-form.component.html' }) export class UserFormComponent implements OnInit { userForm: FormGroup; constructor(private fb: FormBuilder) {} ngOnInit(): void { this.userForm = this.fb.group({ name: ['', Validators.required], email: ['', [Validators.required, Validators.email]], age: ['', [Validators.required, Validators.min(18)]] }); } onSubmit(): void { if (this.userForm.valid) { console.log('Form Submitted', this.userForm.value); this.userForm.reset(); // This doesn't clear the inputs } } } ``` In my HTML template, I have the following: ```html <form [formGroup]="userForm" (ngSubmit)="onSubmit()"> <input formControlName="name" placeholder="Name"> <input formControlName="email" placeholder="Email"> <input formControlName="age" type="number" placeholder="Age"> <button type="submit">Submit</button> </form> ``` After the form is submitted, I expect all the fields to be empty, but they retain the values that were previously entered. I have also tried using `reset({})` to explicitly provide an empty object, but the issue persists. I have verified that the `onSubmit()` method is being called and that the validation works correctly. Could this be related to a specific version of Angular? I am currently using Angular 14.1.0. Any insights on why the form values are not clearing would be greatly appreciated! Any feedback is welcome!