On my NgOnInit() I´m creating a new form like this.
ngOnInit(){
this.expenseForm = this.fb.group({
type: '',
expenses: this.fb.array([this.buildExpense()])
})
}
I have a key called type that starts empty on my object and a key called expenses
these expenses key receive an array every time the user clicks a button.
buildExpense(): FormGroup {
return this.fb.group({
description: '',
quantity: '',
price: ''
})
}
addExpense(): void {
this.expenses.push(this.buildExpense())
}
Html
<button class="btn btn-outline-primary add" type="button" (click)="addExpense()">Add Expense</button>
My objective is to remove the last array add on my form group