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
In Ivy, pipes uses providers from a host component where ViewEngine did not #36146
Comments
Thnx for reporting the issue and providing the reproduce scenario! We will look into this one but if you want to speed up things and help us investigate, providing a minimal, runnable reproduce scenario with https://ng-run.com/ would help immensely! |
Sure thing, here you go: |
I briefly looked into this and found that the pipe in Ivy is able to see There's no static inputs going here, as a pipe can only be present in a a dynamic binding. I'll update the title to this effect. |
Tracking in FW-2012 |
…n a component input Given a structure of `<parent><child [input]="value | pipe"></child></parent>` the injector that is associated with the pipe will inject as if it's placed inside of the `child` component. The issue comes from the fact that we don't have a `TNode` tied to pipe instances and the current `TNode` points to the `child`. These changes work around the issue by having a flag that indicates whether we're currently "inside of" a pipe, and if we are, DI is essentially treated as if it has `SkipSelf`. Fixes angular#36146.
…n a component input Given a structure of `<parent><child [input]="value | pipe"></child></parent>` the injector that is associated with the pipe will inject as if it's placed inside of the `child` component. The issue comes from the fact that we don't have a `TNode` tied to pipe instances and the current `TNode` points to the `child`. These changes work around the issue by having a flag that indicates whether we're currently "inside of" a pipe, and if we are, DI is essentially treated as if it has `SkipSelf`. Fixes angular#36146.
…t node The flag that determines whether something should be able to inject from `viewProviders` is opt-out and the pipes weren't opted out, resulting in them being able to see the `viewProviders` if they're placed on a component host node. Fixes angular#36146.
…t node The flag that determines whether something should be able to inject from `viewProviders` is opt-out and the pipes weren't opted out, resulting in them being able to see the `viewProviders` if they're placed on a component host node. Fixes angular#36146.
…t node The flag that determines whether something should be able to inject from `viewProviders` is opt-out and the pipes weren't opted out, resulting in them being able to see the `viewProviders` if they're placed on a component host node. Fixes angular#36146.
…t node The flag that determines whether something should be able to inject from `viewProviders` is opt-out and the pipes weren't opted out, resulting in them being able to see the `viewProviders` if they're placed on a component host node. Fixes angular#36146.
…t node The flag that determines whether something should be able to inject from `viewProviders` is opt-out and the pipes weren't opted out, resulting in them being able to see the viewProviders if they're placed on a component host node. Fixes angular#36146.
…t node The flag that determines whether something should be able to inject from `viewProviders` is opt-out and the pipes weren't opted out, resulting in them being able to see the viewProviders if they're placed on a component host node. Fixes angular#36146.
@JoostK |
The fix for your case, after the changes have been applied, is to switch from |
Ok, can confirm it works using Edit: To be honest, it feels very strange to use |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 bug report
Affected Package
@angular/core
Is this a regression?
Yes, works without ivy
Description
I think it's related to this #34227 but i'm not really sure.
What i have is a component let's say
component1
that passes an Input to another componentcomponent2
andcomponent2
shows it as-is.The problem is that this input gets transformed by a pipe that retrieves via injector the informations to transform this Input. This informations is stored component-wise.
component2
also provides it, but for his own data.Unfortunately, the pipe in question, used in the template of
component1
ends up using the dependency declared incomponent2
, probably because the execution gets delegated after change detection has been run, therefore the context of the pipe changesI'm not honestly sure my English is good enough to explain this properly but luckily i have a repro
🔬 Minimal Reproduction
repo: https://github.com/EmaGht/ivypipe
ng-run version: https://ng-run.com/edit/32k314W605UdYOdVEPCE
Steps:
git clone https://github.com/EmaGht/ivypipe.git
cd ivypipe
npm install
ng serve
check out the on-screen debug informations
For now i think i can work around it telling the pipe explicitly which context should be used but... meh
The text was updated successfully, but these errors were encountered: