8000 ngOnDestroy not called on service declared using useClass · Issue #28857 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content
ngOnDestroy not called on service declared using useClass #28857
Closed
@Humberd

Description

@Humberd

🐞 bug report

Affected Package

The issue is caused by package @angular/core

Is this a regression?

I don't know

Description

When declaring a service as a component provider by the structure below Angular doesn't call ngOnDestroy method declared in BaseClass when a component is being destroyed.

abstract class BaseClass implements OnDestroy {
	ngOnDestroy() {
		console.log('destroying'); //this is not called
	}	
}

class FooClass extends BaseClass {
}
{
	provide: BaseClass,
	useClass: FooClass
}
6B69

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-service-destroy

🌍 Your Environment

Angular Version:

@angular-devkit/architect         0.11.3
@angular-devkit/build-angular     0.11.3
@angular-devkit/build-optimizer   0.11.3
@angular-devkit/build-webpack     0.11.3
@angular-devkit/core              7.1.3
@angular-devkit/schematics        7.1.3
@angular/cdk                      7.1.1
@angular/material                 7.1.1
@ngtools/webpack                  7.1.3
@schematics/angular               7.1.3
@schematics/update                0.11.3
rxjs                              6.2.2
typescript                        3.1.6
webpack                           4.23.1

But it also appears on 7.2.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0