I am new to angular2
I have a button in parent component, if
There are two ways to call router outlet child component method from the parent component.
ViewChild/ViewChildren - You can use ViewChild/ViewChildren to get the element(s) or the directive(s) matching the selector from the view DOM. It doesn't matter child component is rendered by router outlet.
import { ViewChild } from '@angular/core'; @ViewChild(HomeComponent) private childComponent: HomeComponent;
Then you can call any method,
this.childComponent.changeTitle();
Demo - call router outlet child component method