Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting up a host for a directive with providers #13

Closed
Dyljyn opened this issue Apr 30, 2018 · 3 comments
Closed

Setting up a host for a directive with providers #13

Dyljyn opened this issue Apr 30, 2018 · 3 comments

Comments

@Dyljyn
Copy link

Dyljyn commented Apr 30, 2018

Problem

I have a use case where a directive makes use of a service.
However, I can not figure out how to set this up with createHostComponentFactory.

I've used AppUnlessDirective from the Angular docs as an example.

const createHost = createHostComponentFactory({
  component: AppUnlessDirective,
  providers: [AppUnlessService]
});

Giving the following error (because it's a directive and not a component?)

TypeError: Cannot read property 'componentInstance' of null

Example code

https://stackblitz.com/edit/spectator-directive-providers?file=app%2Fapp-unless.directive.spec.ts

@NetanelBasal
Copy link
Member

I see where is the problem, let me investigate.

@NetanelBasal
Copy link
Member

It's not related to the service, it's related to the structural directive.

@NetanelBasal
Copy link
Member

Fixed in 1.4.4

https://stackblitz.com/edit/spectator-structural-directive-y16jdw?file=app/app-unless.directive.spec.ts

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants