I have parent and child component, from child need to trigger the parent component function.
Parent.component.ts
loadData(event) {
console.log(event);
}
Parent.component.html
<app-project (uploaded)="loadData($event)" ></app-project>
child.component.ts
@Output() uploaded:EventEmitter<any> = new EventEmitter();
ngOnInit() {
this.uploaded.emit('complete'); // Worked
}
loadProject(){
this.uploaded.emit('complete'); // Not triggering the parent function
}
child.component.html
<button type="button" (click)="loadProject(project)" label="Load Project"></button>
Don't know what is the wrong in this, but workes from ngOnInit.
Calling the loadProject from child.component.html.
loadProject()being called from? - Günter ZöchbauereditProject()is called from. - Günter ZöchbauersomeMethod($event)will be called in both cases. How doessomeMethod() { ... }look like? - Günter Zöchbauer