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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

The @ViewChild decorator does not select providers defined through a string token #38313

Closed
ghost opened this issue Jul 31, 2020 · 1 comment
Closed
Assignees
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Jul 31, 2020

馃悶 bug report

Affected Package

The issue is caused by package @angular/core.

Is this a regression?

Yes. This bug was not present before version 9 when Ivy was enabled by default. With ViewEngine, this bug is not present.

Description

In the documentation for the @ViewChild decorator, one of the accepted selectors is stated as:

Any provider defined through a string token (e.g. @ViewChild('someToken') someTokenVal: any)

However, with Ivy enabled, using this type of selector returns an undefined value. With ViewEngine, it works as described and returns a value.

馃敩 Minimal Reproduction

https://stackblitz.com/edit/view-child-string-token-provider-selector

馃敟 Exception or Error

No error, @ViewChild just returns an undefined value.

馃實 Your Environment

Angular CLI: 10.0.4
Node: 12.9.0
OS: darwin x64

Angular: 10.0.7
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.4
@angular-devkit/build-angular     0.1000.4
@angular-devkit/build-optimizer   0.1000.4
@angular-devkit/build-webpack     0.1000.4
@angular-devkit/core              10.0.4
@angular-devkit/schematics        10.0.4
@angular/cli                      10.0.4
@ngtools/webpack                  10.0.4
@schematics/angular               10.0.4
@schematics/update                0.1000.4
rxjs                              6.5.5
typescript                        3.9.7
webpack                           4.43.0
@sonukapoor sonukapoor added area: core Issues related to the framework runtime engine: ivy labels Jul 31, 2020
@ngbot ngbot bot added this to the needsTriage milestone Jul 31, 2020
@crisbeto crisbeto self-assigned this Aug 1, 2020
crisbeto added a commit to crisbeto/angular that referenced this issue Aug 1, 2020
Queries weren't matching directives that provide themselves via string injection tokens, because the assumption was that any string passed to a query decorator refers to a template reference.

These changes make it so we match both template references and providers while giving precedence to the template references.

Fixes angular#38313.
Fixes angular#38315.
crisbeto added a commit to crisbeto/angular that referenced this issue Aug 1, 2020
Queries weren't matching directives that provide themselves via string
injection tokens, because the assumption was that any string passed to
a query decorator refers to a template reference.

These changes make it so we match both template references and
providers while giving precedence to the template references.

Fixes angular#38313.
Fixes angular#38315.
crisbeto added a commit to crisbeto/angular that referenced this issue Aug 9, 2020
Queries weren't matching directives that provide themselves via string
injection tokens, because the assumption was that any string passed to
a query decorator refers to a template reference.

These changes make it so we match both template references and
providers while giving precedence to the template references.

Fixes angular#38313.
Fixes angular#38315.
AndrewKushnir pushed a commit that referenced this issue Aug 10, 2020
Queries weren't matching directives that provide themselves via string
injection tokens, because the assumption was that any string passed to
a query decorator refers to a template reference.

These changes make it so we match both template references and
providers while giving precedence to the template references.

Fixes #38313.
Fixes #38315.

PR Close #38321
profanis pushed a commit to profanis/angular that referenced this issue Sep 5, 2020
Queries weren't matching directives that provide themselves via string
injection tokens, because the assumption was that any string passed to
a query decorator refers to a template reference.

These changes make it so we match both template references and
providers while giving precedence to the template references.

Fixes angular#38313.
Fixes angular#38315.

PR Close angular#38321
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants