Skip to content

HostDirectives doesnt provide the hosted directives when inherited #51203

@iRoyPeleg

Description

@iRoyPeleg

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

Yes

Description

Hi,

I have encountered an issue where hostDirectives doesn't provide with inheritance:

  1. Create a standalone CustomDirective:
    image

  2. Create BaseComponent that uses the CustomDirective via hostDirectives:
    image

  3. Inject the CustomDirective in BaseClass via inject() method:
    image

  4. Create ExtendsComponent that extends via inheritence the BaseComponent:
    image

If you try to run the application, it complains about missing provision for said directive:
image

If manually provides the CustomDirective inside the ExtendsComponent it works:
image

Please provide a link to a minimal reproduction of the bug

https://stackblitz-starters-icp5kn.stackblitz.io

Please provide the exception or error you saw

ERROR NullInjectorError: R3InjectorError(Standalone[App])[CustomDirective -> CustomDirective -> CustomDirective]: 
  NullInjectorError: No provider for CustomDirective!

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 16.1.4
Node: 18.16.1
Package Manager: npm 6.14.17
OS: win32 x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1601.4
@angular-devkit/core         16.1.4
@angular-devkit/schematics   16.1.4
@schematics/angular          16.1.4

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions