Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using @ViewChild in a component
@ViewChild(HelloComponent) hello: HelloComponent;
@ViewChild('template') template: TemplateRef<any>;
@ViewChild('element') element: ElementRef;
@ViewChild('container', { read: ViewContainerRef }) container: ViewContainerRef;
ngAfterViewInit() {
console.log(this.hello);
console.log(this.template);
console.log(this.element);
console.log(this.container);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.