Save the value of the observable array in a local array and use it to add more users, since the remote server link it does not allow to edit the data, it is test.
user.component.ts
users: User[];
getUsers() {
return this.userService.getUsers().subscribe(users => this.users = users);
}
user.service.ts
getUsers(): Observable<User[]> {
return this.http.get<User[]>('http://jsonplaceholder.typicode.com/users');
}
I do not know if I'm going wrong, but the idea that I have would be to obtain the data from the remote database only when the variable of the local array is empty and from there, manipulate the data from said local variable.
getUsers() {
if (this.users == null) {
this.users = this.userService.getUsers()
.subscribe(users => this.users = users as User[]);
}
return this.users;
}