You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using viewChild/viewChildren with private property should be an error #54863
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Using a private property (e.g. #children) with viewChildren() or viewChild() will silently fail, and never update the counts. This is likely also the same for contentChild() and contentChildren(). This also means that retrieving the signal in an effect() will also never trigger outside of the initial run.
Current workaround is to use private myProp = viewChildren('selector');, which will work as intended while still hiding the property from being public.
Please provide a link to a minimal reproduction of the bug
changed the title [-]Using viewChild/viewChildren with private property breaks[/-][+]Using viewChild/viewChildren with private property should be an error[/+]on Mar 14, 2024
Activity
[-]Using viewChild/viewChildren with private property breaks[/-][+]Using viewChild/viewChildren with private property should be an error[/+]alxhub commentedon Mar 14, 2024
This shouldn't be allowed by the compiler in the first place. I believe we want to enforce that such properties are at least
protected.csvn commentedon Mar 14, 2024
That's perfectly fine to produce an error, if unsupported. It was just a headache to find out the reason why the code was not working 😅
fix(compiler-cli): report errors when initializer APIs are used on pr…
fix(compiler-cli): report errors when initializer APIs are used on pr…
fix(compiler-cli): report errors when initializer APIs are used on pr…
angular-automatic-lock-bot commentedon Apr 27, 2024
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.