My goal is, from the child component, I want to call a method in the parent and get the return value. I tried the following approach but was not successful.
In parent.html
<child-component [config]="getConfig(data)"></child-component>
In parent.ts
data = <some data>
...
getConfig(val) {
// format value and return
return formattedVal;
}
In child.ts
@Input() config: Function
...
retrieve() {
const conf = this.config();
}
I am getting an error "this.config is not a function"
Also, I tried using EventEmitter but this time, it returned "undefined"
In parent.html
<child-component (config)="getConfig(data)"></child-component>
In child.ts
@Output() config = new EventEmitter();
...
retrieve() {
const conf = this.config.emit;
}