Property '' does not exist on type 'Object'. Observable subscribe

后端 未结 3 1472
时光说笑
时光说笑 2021-01-01 16:24

I have just started with Angular2 and I\'ve got an issue I cannot really understand.

I have some mock data created as such:

export const WORKFLOW_DAT         


        
3条回答
  •  感情败类
    2021-01-01 17:00

    The return type if your method is Observable. So when you subscribe, that will be the type passed. And there is no testDataArray on the Object type. You can do a couple things:

    1. Type the data and return type differently

      WORKFLOW_DATA: { testDataArray: any } = []
      
      getWorkflowForEditor(): Observable<{ testDataArray: any }>
      
    2. Or just type assert the response data to any

      console.log( (WORKFLOW_DATA).testDataArray );
      

    提交回复
    热议问题