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);
    }


  }


No comments:

Post a Comment

Thank You For Your Great Contribution

Featured Post

how to find duplicate item from array using multiple object keys in angular or javascript

 how to find duplicate item from array using multiple object keys There is a way to find based of multiple key find duplicate records in ang...

Popular Posts