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?
ParentComponent
HTML
<app-list (requestFetch)="fetch($event)"></app-list>
TypeScript
fetch(stuff) {
console.log('fetching'); //this doesn't get called...
this.dataservice.get().subscribe(data=>{
console.log('fetched');
stuff(data);
});
}
Listcomponent
@Output()
requestedFetch:EventEmitter<Function> = new EventEmitter<Function> );
constructor()
{
console.log('requesting data');
this.requestedFetch.emit(this.setData);
}
setData(data) {
console.log('found data');
//do stuff with the fetched Data
}
EDIT Changed onRequestedFetch to requestedFetch and added comments. still doesn't work :(