How to remove multiple item from FormArray

 How to remove multiple item from FormArray


Call Method at any component :-
this.removeItems(formArray, formcontrolCountryID, 2); 

Method Defination :-

removeItems(formArray, formcontrolCountryID, TypeID) {
    const items: any = formArray.value.filter(x => x.CountryID == formcontrolCountryID.value && x.TypeID == TypeID);
    if (items && items.length > 0) {
      formArray.controls.forEach((element, j) => {
        if (element.get('CountryID').value == formcontrolCountryID.value && element.get('TypeID').value == TypeID) {
          formArray.removeAt(j);
        }
      });
      this.removeItems(formArray, formcontrolCountryID, TypeID);
    }


  }


Featured Post

How To Dynamic Upload multiple files with extra detail of model in asp.net core

 How To Dynamic Upload multiple files with extra detail of model in asp.net core  1). firstly create Model File  namespace MyModel {     pub...

Popular Posts