I have an html structure with a component inside a component (forgot the proper word for it).
working basicly like this (largely simplified):
main html:
Since you are adding or deleting element in existing array angular is not able to pick the changes.
For this to work you can do like
items= items.slice();Object.assign method as items= Object.assign([],items);To manually fire change detection you can follow answer on this link
Inject ChangeDetectorRef in your component and then use detectChanges() method of that object to fire change detection manually.
constructure(private cd: ChangeDetectorRef) {}
someMethod() {
this.cd.detectChanges();
}
If you use a spread operator instead of push it should work.
this.data = [...this.data, newItem];
The reason for this is that angular detects a change when the whole object changes, or the reference changes, so a mutation isn't going to trigger it. So rather than mutating the array, you need to make it a new array.