I have a report.service.ts
that have one simple method to get reports
(which is just a const array of reports object from a mock), and all it really does is this:
@Injectable()
export class ReportService {
getReports() {
var ret = Observable.create(function(observer){ observer.onComplete(REPORTS) });
return ret;
}
}
now in my app.component
I want to get those reports. So I did:
@Component({
selector: 'workPrioritizer-reports',
styles: [require('./app.css')],
template: require('./app.component.html'),
})
export class ReportsCmp implements OnInit{
reports: Report[];
title = 'Reorder List';
constructor(private reportService: ReportService) {}
getReports() {
var sub = this.reportService.getReports().subscribe(function(x){return x});
return sub;
}
ngOnInit() {
this.getReports()
}
}
this is it, but its not working, obviously im doing something wrong here, im new to observables :/
thanks!