ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 275.4k

error property subscribe doesn’t exist on type void when sub

May 25 2020 2:28 PM

I work on angular 7 app I face error property subscribe doesn't exist on type

void when subscribe data from service .

My data static as below on service for test
  1. allReportCategories:any[];  
  2. ngOnInit() {  
  3.   
  4.   
  5.        this._displayreport.getallReportCategories().subscribe((data: any[]) => {    
  6.         this.allReportCategories = data;    
  7.   
  8.       });   
  9. }  
on display report service ts
  1. allReportCategories:any[];  
  2.   
  3.   
  4. getallReportCategories(){  
  5.   
  6.     return   
  7.   
  8.      this.allReportCategories=[  
  9.     {  
  10.         "reportCategoryID": 1,  
  11.         "reportCategory""Dashboard Parametric",  
  12.         "isDeleted"false,  
  13.         "menuIcon""icon-home"  
  14.     },  
  15.     {  
  16.         "reportCategoryID": 2,  
  17.         "reportCategory""Monitor Reports",  
  18.         "isDeleted"false,  
  19.         "menuIcon""icon-list"  
  20.     },  
  21.     {  
  22.         "reportCategoryID": 3,  
  23.         "reportCategory""Other Reports",  
  24.         "isDeleted"false,  
  25.         "menuIcon""icon-docs"  
  26.     },  
  27.     {  
  28.         "reportCategoryID": 4,  
  29.         "reportCategory""PCN Flow",  
  30.         "isDeleted"false,  
  31.         "menuIcon""icon-list"  
  32.     },  
  33.     {  
  34.         "reportCategoryID": 5,  
  35.         "reportCategory""Compliance By Document",  
  36.         "isDeleted"false,  
  37.         "menuIcon""icon-home"  
  38.     }  
  39. ];  
  40.   
  41.   }  

sample exist on stackbliz as below :

https://stackblitz.com/edit/create-1arrvm?file=app%2Fdisplayreport.service.ts  

Answers (1)