Currently, I am facing an issue with calling a method from the child component to the parent component in Angular 4 using .emit();
In my app.component.html file:
<parent-component (loadMoreData)="loadData()"></parent-component>
The Parent Component's HTML looks like this:
<div>
<child-component [dataList]="dataList"></child-component>
</div>
Inside the Parent Component.ts file,
public dataList : Array<any>;
constructor() {
this.loadData();
}
ngOnInit() {
}
loadData(){
//const options = this.getOptions();
this.appServices.getDataList().subscribe((response) => {
const respJson = response;
this.dataList = respJson;
console.log(this.assayDataList);
});
}
And in the Child component.ts file,
@Output() loadMoreData : EventEmitter<boolean>;
public getRowData():Promise<any[]>{
var self = this;
return new Promise((resolve)=>{
self.loadMoreData.emit(true);
resolve(this.assayTableData);
})
}
However, I'm encountering an error message:
Error: Uncaught (in promise): TypeError: Cannot read property 'emit' of undefined
I'm puzzled by this error. Can someone guide me on what could be wrong here?