I have a form with a telephone field, when you click on the Add button, a new field will appear. What is happening is that when I click on Add, the value typed on the previous fields get reset. I managed to make it work by removing the "form" tags, but I need this form on my project. How can I make it work using "form"?
HTML
<form>
<div *ngFor="let phonecount of phonecount; let i = index" class="form-group">
<label>Optional Phone </label>
<input type="text" class="form-control" [(ngModel)]="user.extraphones[i]" name="phone2">
</div>
<input (click)="onSubmito()" type="submit" value="Add" class="btn btn-primary">
</form>
TS
user = {
name:'',
phone:'',
extraphones:[]
};
namee='';
phonecount:string[]=[''];
onSubmito(){
this.phonecount.push(this.namee);
}