Skip to content

ngOnInit is called multiple times in production mode if an error happens in it #15925

@tbosch

Description

@tbosch

This is because we are setting ViewState.FirstCheck not until a view has been fully change detected.

Solution:

detectChanges(view: ViewData) {
  view.wasFirstCheck = view.firstCheck;
  view.firstCheck = false;
  // dirty check all directives, use view.wasFirstCheck instead of view.firstCheck.  
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions