feat(forms): clear (remove all) components from a FormArray (#28918)
This method is a more convenient and efficient way of removing all components from a FormArray. Before it, we needed to loop the FormArray removing each component until empty. Resolves #18531 PR Close #28918
This commit is contained in:

committed by
Kara Erickson

parent
014841dfef
commit
a68b1a1894
@ -59,6 +59,20 @@ import {of } from 'rxjs';
|
||||
expect(a.controls).toEqual([c1, c3]);
|
||||
});
|
||||
|
||||
it('should support clearing', () => {
|
||||
a.push(c1);
|
||||
a.push(c2);
|
||||
a.push(c3);
|
||||
|
||||
a.clear();
|
||||
|
||||
expect(a.controls).toEqual([]);
|
||||
|
||||
a.clear();
|
||||
|
||||
expect(a.controls).toEqual([]);
|
||||
});
|
||||
|
||||
it('should support inserting', () => {
|
||||
a.push(c1);
|
||||
a.push(c3);
|
||||
|
Reference in New Issue
Block a user