Skip to content

Lifecycle hooks are not called when extends a class #23091

Description

@tinayuangao

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x ] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

In material tree, the MatTreeNestedNode extends a mixin of CdkTreeNestedNode. CdkTreeNestedNode has ngAfterContentInit and ngOnDestroy https://github.com/angular/material2/blob/master/src/lib/tree/node.ts#L89
But the ngAfterContentInit and ngOnDestroy functions are not called in MatTreeNestedNode.
https://github.com/angular/material2/blob/master/src/cdk/tree/nested-node.ts#L71
This only happen in aot mode (in new angular-cli, the --prod mode)

We have the issue in material: angular/components#10437

Expected behavior

The lifecycle hooks in MatTreeNestedNode should be called when it extends from CdkTreeNestedNode.

Minimal reproduction of the problem with instructions

Same reproduction in angular/components#10437

git clone https://github.com/DocLM/nested-tree-example
npm i -g @angular/[email protected]

Then run
ng serve --prod <--- This case the nested nodes are not expandable, because the lifecycle hooks are not called
ng serve <-- This case the nested nodes are expandable and working properly

What is the motivation / use case for changing the behavior?

Environment


Angular version: X.Y.Z


Browser:
- [x ] Chrome (desktop) version 64.0.3282.186 
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: v8.9.4  
- Platform:  Linux 

Others:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: coreIssues related to the framework runtime

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions