Currently, I am in the process of modifying a collection of data that is being shown on app.component.html
<ul>
<li *ngFor="let data of DataSource">
{{ data.id }} - {{data.title}}
</li>
</ul>
So far, I have successfully added a new row of data using the method below:
create() {
const newPostId = this.postId + 1;
this.apiService.create(newPostId, this.postTitle, this.postText).subscribe(result => {
const newId = result['id'];
this.retrieveData.push({id: newId, title: this.postTitle});
this.dataCount = this.dataCount + 1;
}, error => console.log('There was an error: ', error));
}
This method effectively adds the new data row to the end of the existing list.
Now, my question arises:
In what way can I modify the create() function to update an existing row and reflect these modifications in the app.component.html?