I am currently working on an Angular 7 application and I have encountered an error stating that the property 'subscribe' does not exist on type void when trying to subscribe to data from a service.
The error is displayed in the subscribe data function within app.component.ts. How can I resolve this issue?
allReportCategories:any[];
ngOnInit() {
this._displayreport.getallReportCategories().subscribe((data: any[]) => {
this.allReportCategories = data;
});
}
In the display report service ts:
allReportCategories:any[];
getallReportCategories(){
return
this.allReportCategories=[
{
"reportCategoryID": 1,
"reportCategory": "Dashboard Parametric",
"isDeleted": false,
"menuIcon": "icon-home"
},
{
"reportCategoryID": 2,
"reportCategory": "Monitor Reports",
"isDeleted": false,
"menuIcon": "icon-list"
},
{
"reportCategoryID": 3,
"reportCategory": "Other Reports",
"isDeleted": false,
"menuIcon": "icon-docs"
},
{
"reportCategoryID": 4,
"reportCategory": "PCN Flow",
"isDeleted": false,
"menuIcon": "icon-list"
},
{
"reportCategoryID": 5,
"reportCategory": "Compliance By Document",
"isDeleted": false,
"menuIcon": "icon-home"
}
];
}
A sample of the code can be found on StackBlitz here:
https://stackblitz.com/edit/create-1arrvm?file=app%2Fdisplayreport.service.ts
To be more specific with my question, what changes should I make to this line of code:
this._displayreport.getallReportCategories().subscribe