Skip to content

Instantly share code, notes, and snippets.

@natmegs
Created January 10, 2018 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natmegs/677a1b212d22d751485774fb9b6a0d0a to your computer and use it in GitHub Desktop.
Save natmegs/677a1b212d22d751485774fb9b6a0d0a to your computer and use it in GitHub Desktop.
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