I have a third-party angular component, which is a table displaying user data. If the transferred object to the table changes, the table is updated.
How does angular detect object changes? I have the following example:
user.component.ts:
@Component({
selector: 'app-user',
templateUrl: './user.component.html',
styleUrls: ['./user.component.css'],
})
export class UserComponent implements OnInit {
private _users: User[];
set users(users: User[]) {
this._users = users;
}
get users(): User[] {
return this._users;
}
constructor() {}
addUserToTheList(user: User) {
this.users.push(user);
let userList: User[] = this.users;
userList.push(user);
this.users = userList;
}
}
Does this mean that I have to completely replace the object in order to cause change detection, or somehow I did not completely miss the point? Or it could be a problem for a third-party library (which Clarity Design System)
source
share