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 remove all quick access file from computer in one time

 How to remove all quick access file from computer in one time  step1: first at all press "Window+R" then open a Run dialog box an...

Popular Posts