import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-parent',
styleUrls: ['./parent.component.css'],
template: `
<app-child [parentApi]="getParentApi()"></app-child>
`,
})
export class ParentComponent implements OnInit {
getParentApi(): ParentComponentApi {
return {
callParentMethod: (name) => {
this.parentMethod(name)
}
}
}
constructor() { }
ngOnInit() {
}
parentMethod(name: string) {
console.log(`Hello ${name} from parent`)
}
}
export interface ParentComponentApi {
callParentMethod: (string) => void
}