Warning!
The Angular v6.1.7 FormArray documentation says:
To change the controls in the array, use the push, insert, or removeAt methods in FormArray itself. These methods ensure the controls are properly tracked in the form's hierarchy. Do not modify the array of AbstractControls used to instantiate the FormArray directly, as that result in strange and unexpected behavior such as broken change detection.
Keep this in mind if you are using the splice
function directly on the controls
array as one of the answer suggested.
Use the removeAt
function.
while (formArray.length !== 0) {
formArray.removeAt(0)
}