I am working with Angular 2 with TypeScript. I have a user management component where I have a table for all users.
When you click any user in the table of the form, all its properties are processed for editing. When a user is selected, an event occurs, as shown below:
onUserSelected(event) { var selectedId = event.data.id; this.selectedUser = this.users.filter(user => user.id === selectedId)[0] }
The problem is when selectedUser is edited, its properties also change in the table, and it doesn't look so good. I tried to create a copy myself, as shown below, but that did not help - user class
clone() { var cloned = new User(this.id, this.login, this.name, this.surname, this.phone); return cloned; }
Maybe I am doing what is not good practice in Angular2?
source share