locked
error property subscribe doesn't exist on type void when subscribe data from service? RRS feed

  • Question

  • User696604810 posted

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

    void when subscribe data from service .

    error display on subscribe data function on app.component.ts so How to solve this issue if possible ?

    allReportCategories:any[];
    ngOnInit() {
    
    
           this._displayreport.getallReportCategories().subscribe((data: any[]) => {  
            this.allReportCategories = data;  
    
          }); 
    }

    on 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"
        }
    ];
    
      }
    sample exist on stackbliz as below :
    
    https://stackblitz.com/edit/create-1arrvm?file=app%2Fdisplayreport.service.ts

    Monday, May 25, 2020 7:56 PM

All replies