0

Below is my code.

getAccountAssociatedDetails(account, index) {
        if (!!account) {
            this.agreementDetailsService.getDetails(account)
                .subscribe((response) => {
                    console.log(response);
                    const rows = <FormArray>this.manualDetailsForm.get('rows');
                    let associatedDetailsArray = <Array<any>>response.associatedDetails;
                    let newItems = [];
                    for (let i = 0; i < associatedDetailsArray.length; i++)
                        newItems.push(this.buildDetail(associatedDetailsArray[i].account, associatedDetailsArray[i].huid, associatedDetailsArray[i].huidName, associatedDetailsArray[i].huidCountry));
                    rows.splice(index, 0, ...newItems);
                });
        }
    }

How to insert new array at a specific position of FormArray.

I'm getting error property splice does not exist on type FormArray. Please help me some other way to do this.

1
  • Thanks! Changed it to for (let i = 0; i < associatedDetailsArray.length; i++) rows.insert(index, this.buildTPIItem(associatedDetailsArray[i].account, associatedDetailsArray[i].huid, associatedDetailsArray[i].huidName, associatedDetailsArray[i].huidCountry)); Commented Sep 28, 2017 at 9:12

1 Answer 1

1

You can use insert method

rows.insert(index, yourControl)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.