Skip to content

Child directive events swallowed when destroyed by directives using viewContainer.remove #5289

@gionkunz

Description

@gionkunz

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions