-This is my curated list-
export const FORMULARLIST: formular[] = [
{ id: 1, name: 'Jane Doe', mobileNumber: 987654, secondMobileNumber: 456789, email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e1bcc0d9eceecccfd8cdc2cecae7c8c5cdcd80c8c5c8cfc7c49c5c5">[email protected]</a>', secondEmail: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c4e9f5ecf9fbf9e4d9f8f3f9e9f3f5ecf1efe9f8f1f4dce6eeef">[email protected]</a>', roomNumber: 'B203', task: "Data Management" },];
-This is the structure of my form-
export interface formular {
id: number;
name: string;
mobileNumber: number;
secondMobileNumber: number;
email: string;
secondEmail: string;
roomNumber: string;
task: string;
}
-Here is the function for adding a new element to the array. However, when I input something in the HTML form field, the list updates automatically-
addNew(){
FORMULARLIST.push(this.formular);
}
-The button triggering the function-
<input (click)="addNew()" type="submit" value="Add" class="btn btn-success" />
-The HTML data with the input box-
<span class="input-group-text" id="basic-addon1">Task:</span>
<input id="newtask" [(ngModel)]="formular.task" type="text" class="form-control" placeholder="Task" aria-label="Username" aria-describedby="basic-addon1">
´´´ I'm struggling with updating only one element in the array without affecting the others ´´´