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

后端 未结 3 1471
时光说笑
时光说笑 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:03

    Typescript expects WORKFLOW_DATA to be Object here:

    .subscribe( WORKFLOW_DATA => {} )
    

    because you told it so:

      getWorkflowForEditor(): Observable
    
    
    

    But Object doesn't have testDataArray property... You should either tell TypeScript that data can have any properties:

      getWorkflowForEditor(): Observable
    

    or use

    console.log( WORKFLOW_DATA["testDataArray"] );
    

    提交回复
    热议问题