Skip to content

Instantly share code, notes, and snippets.

@ldmarz
Created August 14, 2018 17:05
Show Gist options
  • Save ldmarz/1f45da80f95cef4042785f82158816d8 to your computer and use it in GitHub Desktop.
Save ldmarz/1f45da80f95cef4042785f82158816d8 to your computer and use it in GitHub Desktop.
import { Component, ViewChild } from '@angular/core';
import { SomeChildComponent } from './someChild/someChild.component';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
@ViewChild(SomeChildComponent) someChildComponent;
callChildFunction() {
console.log(this.someChildComponent); // Here you have one reference to your child component
this.someChildComponent.callSomeFunction();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment