Skip to content

When compiling with AOT, ngOnDestroy is not automatically created #1

Open
@happycollision

Description

@happycollision

When a task is created on a component, the task either uses the existing ngOnDestroy method, or creates one on the component. The AOT compiler somehow prevents the latter from working.

This only affects components where both of the following are true:

  1. The component will ultimately be compiled using AOT. (ng serve --aot, ng build --prod in Angular 5 and beyond, etc.)
  2. The component does not define ngOnDestroy

The workaround:
Define ngOnDestroy on your component. Just an empty function will do:

class SomeComponent extends Component {
  ngOnDestroy() {}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions