0

I have an array that contain multiple objects as shown below.

this.list = [
 {
  "image": "imageurl1",
  "name": "itemname1"
 },
 {
  "image": "imageurl2",
  "name": "itemname2"
 },
 {
  "image": "imageurl",
  "name": "itemname3"
 }
]

Above list is just an example array, not real one. Below is app-folder is another component where I have applied folderList array to iterate through whole list.

<app-folder *ngFor="let folder of documentsData.folderList" [documentsData]="documentsData" [folderData] = "folder"
                [folderList]="documentsData.folderList" (processAction) = "refreshFolders($event)"></app-folder>

Showing the data in angular material card. Here I am trying to change the name of any item by calling an api (this is to update db). Once I make such changes and update list variable, whole list blink on front end.

Functionality is working fine, but I don't want to whole list to blink, rather I want only particular item to reflect change or blink.

How to update only once item that has been changed and update *ngFor to reflect that. Is there any way to handle that?

Umair Jameel
  • 1,573
  • 3
  • 29
  • 54

1 Answers1

1

You will have to append or modify only that given entry in list. Otherwise, if you do something like

this.list = myNevListFromService

Anguar detects that collection has changed (not elelents of collection) thus recreates whole collections representation.

If you would only update single entry, it would not happen. Besides that, there can be couple of more reasons that can cause this, but you must share code to detect that

Antoniossss
  • 31,590
  • 6
  • 57
  • 99