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
}