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

Component-level injectors don't work #1622

Closed
franzeal opened this issue Jun 9, 2019 · 9 comments · Fixed by #1651
Closed

Component-level injectors don't work #1622

franzeal opened this issue Jun 9, 2019 · 9 comments · Fixed by #1651
Labels

Comments

@franzeal
Copy link
Contributor

franzeal commented Jun 9, 2019

I'm submitting a ...

[x] bug report
[ ] feature request
[ ] support request

Current behavior
In version 5, component-level injectors do not work.

Expected behavior
Component-level injectors should work.

Minimal reproduction of the problem with instructions
Below is a demonstration of component-level injectors. I'm demonstrating a parent/child relationship of wrappers (A) and components (B) (these don't behave differently, which is expected). In the console, each parent/child logs its service dependency. The expectation is that all parent/child log output should have the service, but in the v5 demo the children receive null.

https://stackblitz.com/edit/ngx-formly-ui-bootstrap-component-injectors-v3 (works)
https://stackblitz.com/edit/ngx-formly-ui-bootstrap-component-injectors-v4 (works)
https://stackblitz.com/edit/ngx-formly-ui-bootstrap-component-injectors-v5 (issue)

What is the motivation / use case for changing the behavior?
Trying to address: franzeal/ngx-formly-tabs#2

  • Angular version:
    Tested with Angular 6 and 7.

  • Browser:
    Chrome 75, Firefox 67

@aitboudad aitboudad added the bug label Jun 10, 2019
@ilijev07
Copy link

Any progress on this one?

@aitboudad
Copy link
Member

I'll check it during this week but not sure if I would find a proper fix, the order of creation field component and its wrappers has been changed and we can't revert it.

@ilijev07
Copy link

ilijev07 commented Jul 4, 2019

Like a workaround for franzeal/ngx-formly-tabs#2 it can be made with providing TabsetService in the module directly instead of component, I tried and it works fine.

@thiagogjt
Copy link

You can provide it on the container component. The drawback is that you cant have more than one tabset in the form...

@aitboudad
Copy link
Member

@franzeal the fix should be landed in ngx-formly-tabs for now the only way to make it work is to set the parent as a type instead of wrapper.

@franzeal
Copy link
Contributor Author

franzeal commented Jul 6, 2019

@aitboudad that works to an extent, certainly enough that I can address the issue on my end. Wanting to keep the usage consistent, I was surprised to see that it won't work if I change both to types:
https://stackblitz.com/edit/ngx-formly-ui-bootstrap-component-injectors-v5-no-wrappers

@aitboudad
Copy link
Member

I think I've got an idea to make it work, let me check it first :)

@aitboudad
Copy link
Member

@franzeal in 5.2 version you can declare both as a type, component-level injectors for field type is now supported (only between field type components) so in ngx-formly-tabs the TabsetService provider should be declared in FormlyFieldTabsetComponent in order to work properly.

@franzeal
Copy link
Contributor Author

franzeal commented Jul 9, 2019

@aitboudad I really appreciate it, thank you!

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

Successfully merging a pull request may close this issue.

4 participants