I am not familiar with Angular 2, 3, 4 & 5 and I am trying to get a better understanding of Angular 6.
Problem: I am pushing an user object to the users array then when I change the value of inputs, all the object inside the array is also changing.
component.ts
public data; //user input id,age,first_name,last_name
public users: User[] = [];
constructor() {
this.data = {};
}
ngOnInit() {
}
btnClick = function () {
//push the user input to array
this.users.push(this.data);
};
Please check my sample code here: https://stackblitz.com/edit/angular-1ztg1k