The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

477844 (1) [Avatar] Offline
#1
I want a generic list component which a ''fetch'' method will be injected to. this didn't work through '@input', so i tried output, but it also doens't work for some reason. how can I do this and why doesn't this work?
Ideally, I want to connect it directly to a service function which returns the data if possible

ParentComponent

HTML

<app-list (onRequestFetch)="fetch($event)"></app-list>
TypeScript

fetch(stuff) {
this.dataservice.get().subscribe(data=>{
stuff(data);
});
}
Listcomponent

@Output()
requestedFetch:EventEmitter<Function> = new EventEmitter<Function> );

constructor()
{
this.requestedFetch.emit(this.setData);
}

setData(data) {
//do stuff with the fetched Data
}