I am working with Angular 2 with TypeScript. I have User Management component where I have table of whole users.
When any user in table is clicked then forms appeaer with his whole properties to edit. Choosing user occurs event as below:
onUserSelected(event) {
var selectedId = event.data.id;
this.selectedUser = this.users.filter(user => user.id === selectedId)[0]
}
The problem is when selectedUser is being edited his properties also changes in table and it doesnt look so good. I tried to create copy myself as below but it didn't help - user class
clone() {
var cloned = new User(this.id, this.login, this.name, this.surname, this.phone);
return cloned;
}
Maybe I am doing something which is not good practice in Angular2?