G
G
Galdar Turin2020-06-02 14:29:29
Angular
Galdar Turin, 2020-06-02 14:29:29

How to work with change detection?

I can’t understand, here I have an array in the object

private obj = {
arr: []
}

This object is in the service, when I add data to it In the component that is connected to this service , change detection immediately fires and my data is drawn. But if suddenly, I do a cleanup of this array Then when I write to this array again, the detection of changes on this array does not work, and new data is not drawn. Similarly, if I have an array with objects
obj.arr.push(1)

obj.arr = []

arr = [
  {id:1,name:'Вася'},
  {id:2,name:'Петя'},
  ...
 ]

When deleting an object in this array with the key ( 1 ) , change detection stops working and when other objects are added, they are no longer tracked...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question