I came across a behaviour when using NgIf and NgFor that I'd not expect. When child directives are removed by NgIf or NgFor using ViewContainer.remove(), any event produced by them just prior to the removal will be swallowed and not be conveyed to the parent directive.
I've created this little example that illustrates the behaviour: http://plnkr.co/edit/9F1I7HRe9Hzpo1qZOHMG?p=preview
The problem does not occur when they are moved by NgFor as the reordering of the data list shows. However, when children get removed (numbers exceed 4), their event is swallowed.
I guess this is a reference problem as children are operating on the data from the parent. At the time when a child directive is updating the data of the parent, the parent will probably kick in with change detection and removes the element before the event was captured. However, I'd expect that, any event that was sent prior removal using ViewContainer will be visible to the parent.
I came across a behaviour when using
NgIfandNgForthat I'd not expect. When child directives are removed byNgIforNgForusingViewContainer.remove(), any event produced by them just prior to the removal will be swallowed and not be conveyed to the parent directive.I've created this little example that illustrates the behaviour: http://plnkr.co/edit/9F1I7HRe9Hzpo1qZOHMG?p=preview
The problem does not occur when they are moved by
NgForas the reordering of the data list shows. However, when children get removed (numbers exceed 4), their event is swallowed.I guess this is a reference problem as children are operating on the data from the parent. At the time when a child directive is updating the data of the parent, the parent will probably kick in with change detection and removes the element before the event was captured. However, I'd expect that, any event that was sent prior removal using
ViewContainerwill be visible to the parent.