I have the following code to push a new item to the very end of the form array:
(<FormArray>this.invoicesForm.get('invoices')).push(this.fBuilder.group({
id: null,
issueDate: [null, Validators.required], // Only fill in and set the required validator for issue date if a custom date has already been chosen
invoiceIssuedStateCode: [0],
canEditIssueDate: [true],
chooseDate: [false],
issued: [false],
paidStatus: [0],
reference: [null],
creditNotes: this.buildCreditNotes([]),
lineItems: this.buildNewLineItems(this.lineItemsRecord.lineItems)
}));
However I need to push this item as the second last item in the array. How would I go about this?