1

I move the controls inside the formArray, have any ideas why when swap elements, the state of the radio-element of the moved control is reset in the template, but the value is stored in the form correctly?

Example, https://stackblitz.com/edit/angular-ivy-81figr?file=src%2Fapp%2Fapp.component.ts

1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Sep 2, 2021 at 18:02

1 Answer 1

1

please change the swap function accordingly;

  public swap(userIndex: number, index1: number, index2: number): void {
    const devices = this.getDeviceArray(userIndex);
    if (index2 > 0 && index1 < devices.controls.length - 1) {
      let v1 = devices.controls[index1].value;
      let v2 = devices.controls[index2].value;
      devices.controls[index2].setValue(v1);
      devices.controls[index1].setValue(v2);
      devices.updateValueAndValidity();
    }
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.