Home > Back-end >  can anyone help me with my add row formarray
can anyone help me with my add row formarray

Time:07-02

my modal and my textbox

enter image description here

once i click the modal

enter image description here

when i click the value in modal table

enter image description here

adding a row

enter image description here

selecting again value for my second row

enter image description here

once i select why my first row get the value too?

enter image description here

angular index for formarray can anyone tell whats wrong with my codes

here's the link of the code

let me know please I'm stuck of this one

CodePudding user response:

Because id:[0]. When you create a new new row you are always pushing same id. When closing your modal ItemDialogComponent, it should return the item selected from the modal (response). Your return response right now is just a string, but make it return an obj. And you pass that returned obj to addRow(response) to be added to this.Form.

CodePudding user response:

Wrap the input in a div and add the formGroupName there instead

<div [formGroupName]="I">
<input>
</div>
  • Related