I use key pipe in a * ngfor loop. Data is transferred in JSON.
@Pipe({ name: 'keys' }) export class KeysPipe implements PipeTransform { transform(value, args: string[]): any { if (!value) { return value; } let keys = []; for (let key in value) { keys.push({key: key, value: value[key]}); } return keys; } }
-
<div *ngFor="let item of jsonObject | keys"> <p>{{ item.value.code }}</p> </div>
The problem is when I delete an item from JSON, ngFor is not updated.
I have already tried two options:
- call this.applicationRef.tick (); after deleting an item without changes
- unclean pipe " pure: false ". This led to the huge memory usage in chrome in hundreds of megabytes, and I had to kill the process.
If there is another way?
Thanks!
source share