Will Angular re-render whole object?

Viewed 23

There is a data I render in template using async.

  private registry = new BehaviorSubject<RegistryGroup[]>([]);

Template is:

*ngFor="let reg of registry | async"

Also there is a function that modifies data and pushed beck to registry:

modify(registryId: number) {
    const updated = this._registry.getValue().map((registry) => {
      if (registry.Id == registryId) {
        registry.opened = true;
      }
      return registry;
    });

    this.registry.next(updated);
  }

Will Angular render whole registry or only changed element registry.opened = true;?

1 Answers

to optimize re-rendering you should use trackBy function, which should return unique (usually id) value for each value in array

Related