How to reorder items in FormGroup?

Discussão em 'Angular' iniciado por Raphaël Balet, Março 18, 2025.

  1. I have element in a FormGroup, let say

    const langs = ['en', 'de']
    form = new FormGroup({
    languages: [langs, [Validators.required]]
    descriptions: initChildGroup(langs)
    })

    initChildGroup(langs) {
    const formGroup: FormGroup = new FormGroup({})

    langs.forEach((lang, index) => {
    formGroup.addControl(lang, new FormControl())
    }
    }


    I now want to move the order of the lang and put 'de' first.
    Moving element in an array is quite an easy task, but how to handle this properly with a FormGroup ?

    Continue reading...

Compartilhe esta Página