I have the following application root:
@Component({
selector: 'my-app',
providers: [],
templateUrl: `<button (click)="callChildFunction()">Close</button>
<router-outlet></router-outlet>`
})
export class AppComponent {
constructor() {
}
callChildFunction(){
}
}
And here is my child (the component used in router-outlet):
@Component({
selector: 'child',
providers: [],
templateUrl: `<div>Hello World</div>`
})
export class ChildComponent {
constructor() {
}
myFunction(){
console.log('success');
}
}
I found that I can use RouterOutlet to get the functions of the component, but it does not seem to be accessible from inside the application root.
How can I call myFunction()from the root of the application?
source
share