Skip to content

docs: life-cycle - directives support "VIEW" lifecycle hooks, the docs say they dont #10221

@shlomiassaf

Description

@shlomiassaf

I'm submitting a ... Hard to say....

Current behavior

  • ngAfterContentInit
  • ngAfterContentChecked
  • ngAfterViewInit
  • ngAfterViewChecked

Fire on directives.

Expected/desired behavior
According to the docs these lifecycle hooks are Components only

  • ngAfterContentInit
  • ngAfterContentChecked
  • ngAfterViewInit
  • ngAfterViewChecked

The compiler registers them to invoke on directives as well.
The view factory of a component containing a directive will invoke the lifecycle hook on that directive. This is not by change, this is by intent from the compiler as it requires accessing the directive instance and calling the hook within the detectChangesInternal method.

Here's a plunker
I can only assume the docs are incorrect...

Metadata

Metadata

Assignees

No one assigned

    Labels

    freq1: lowhelp wantedAn issue that is suitable for a community contributor (based on its complexity/scope).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions