one component in ng-template cannot query by @ViewChild whenever set static true or false in ng8
See original GitHub issue🐞 bug report
Affected Package
The issue is caused by package @angular/core
Is this a regression?
this behavior is only in ng8
Description
one component in ng-template cannot query by @ViewChild whenever set static true or false in ng8
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-j3besy
🔥 Exception or Error
html:
<ng-template>
<hello name="{{ name }}"></hello>
</ng-template>
ts:
@ViewChild(HelloComponent, {static: false}) hello: HelloComponent;
ngOnInit() {
console.log(this.hello)
}
ngAfterViewInit() {
console.log(this.hello)
}
🌍 Your Environment
Angular Version:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 8.0.3
Node: 10.16.0
OS: win32 x64
Angular: 8.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.800.3
@angular-devkit/build-angular 0.800.3
@angular-devkit/build-optimizer 0.800.3
@angular-devkit/build-webpack 0.800.3
@angular-devkit/core 8.0.3
@angular-devkit/schematics 8.0.3
@angular/cli 8.0.3
@ngtools/webpack 8.0.3
@schematics/angular 8.0.3
@schematics/update 0.800.3
rxjs 6.4.0
typescript 3.4.5
webpack 4.30.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
How should I use the new static option for @ViewChild in ...
In ng8 , you can manually set when to access the child component in the parent component. When you set static to true,...
Read more >Can't use ViewChild to get Component in ngAfterViewInit() by ...
We have validated your reported query. In Angular, we cannot access the reference of child elements when placed inside the ng-template.
Read more >@ViewChild static: true or false | Part 29 - YouTube
Angular #mututorial #ViewChildIn this video you will when to use static True & False.
Read more >ngTemplateOutlet: The secret to customisation - Angular inDepth
ngTemplateOutlet is a powerful tool for creating customisable components. It is used by many Angular libraries to enable users to provide custom templates....
Read more >Angular: @ViewChild() and @ContentChildren() decorators
The result of the query is dynamic and updated when the DOM changes. Given the following HTML settings-panel.component.html : 1 2 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mlc-mlapis yes,i got it, thank you
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.