I have requirement where i can add dynamic row or remove row, here is my code
ngOnInit{
this.rows.push({
id:'',
name:'',
age:''
})
addRow(){
let a= {
id:'',
name:'',
age:''
}
this.rows.push(a)
}
deleteRow(index){
this.rows.splice(index,1)
}
}
the issue is suppose i have three rows i have entred value in all three rows ,if i delete second rows and added third row, second and third row fields become blank
<div *ngFor="item in rows;let i =index;">
<div>
<input type="text" name="name{i}" [(ngModel)]="item.name"> delete/add button here
</div>
</div>.