I'm working with Angular's HttpClient for CRUD operations. I have an edit option for each record, but I want to be able to update multiple records at once by selecting checkboxes and clicking the update button.
Could you please assist me in implementing this feature? I need to add a checkbox for each row so that users can select multiple records, then click on the edit button, select the updated option, and finally click the update button to apply changes to all selected records.
Additionally, it would be very helpful if I could get a count of how many records are applicable, not applicable, and FYI out of the total.
common.service.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class CommonService {
constructor(private http:HttpClient) { }
createUser(user: any) {
return this.http.post("http://localhost:3000/users", user);
}
getAllUser() {
return this.http.get("http://localhost:3000/users");
}
updateUser(user: any): Observable<any> {
return this.http.put("http://localhost:3000/users/" + user.id, user);
}
deleteUser(user: any) {
return this.http.delete("http://localhost:3000/users/" + user.id);
}
}
app.component.ts
app.component.html
db.json